#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000000;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int> b = a;
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  sort(b.begin(), b.end(), greater<int>());
  for (int i = 0; i < n; ++i) {
    int ans = (b[0] == a[i] ? b[1] : b[0]);
    cout << ans << endl;
  }
  return 0;
}
