#include <bits/stdc++.h>
using namespace std;
int gcdEx(int a, int b, int *x, int *y) {
  if (!a) {
    *x = 0;
    *y = 1;
    return b;
  }
  int x1, y1, gcd = gcdEx(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
int modI(int b, int m) {
  int x, y;
  gcdEx(b, m, &x, &y);
  return (x % m + m) % m;
}
long long modP(long long x, long long y) {
  long long r = 1;
  x %= 1000000007;
  while (y > 0) {
    if (y & 1) {
      r = (r * x) % 1000000007;
    }
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return r;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  int begtime = clock();
  ;
  long long t, sum = 0, ans = 0, n;
  cin >> n;
  vector<long long> v(n), u;
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) {
    t = v[i];
    v[i] = INT_MIN;
    ans = (*max_element((v).begin(), (v).end()));
    cout << ans << "\n";
    v[i] = t;
  }
  return 0;
}
