#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
using P = pair<long long, long long>;
void chmin(long long &a, long long b) {
  if (a > b) a = b;
}
void chmax(long long &a, long long b) {
  if (a < b) a = b;
}
void pmod(long long &a, long long b) { a = (a + b) % MOD; }
void pmod(long long &a, long long b, long long c) { a = (b + c) % MOD; }
void qmod(long long &a, long long b) { a = (a * b) % MOD; }
void qmod(long long &a, long long b, long long c) { a = (b * c) % MOD; }
long long median(long long a, long long b, long long c) {
  return a + b + c - max({a, b, c}) - min({a, b, c});
}
void ans1(bool x) {
  if (x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void ans2(bool x) {
  if (x)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void ans3(bool x) {
  if (x)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
}
void ans(bool x, long long y, long long z) {
  if (x)
    cout << y << endl;
  else
    cout << z << endl;
}
void ans(bool x, string y, string z) {
  if (x)
    cout << y << endl;
  else
    cout << z << endl;
}
void debug(vector<vector<long long>> v, long long h, long long w) {
  for (long long i = 0; i < h; i++) {
    for (long long j = 0; j < w; j++) cout << v[i][j] << " ";
    cout << endl;
  }
};
long long gcd(long long x, long long y) {
  long long r;
  while ((r = x % y) != 0) {
    x = y;
    y = r;
  }
  return y;
}
int main() {
  long long i, j, o;
  long long res = 0, res1 = INF, res2 = -INF, buf = 0;
  bool judge = true;
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    sort((b).rbegin(), (b).rend());
  }
  for (i = 0; i < n; i++) {
    if (a[i] == b[0])
      cout << b[1] << endl;
    else
      cout << b[0] << endl;
  }
  return 0;
}
