#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
  int n, f = 0;
  cin >> n;
  int a[n + 1], b[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    f = 0;
    for (int j = 1; j <= n; j++) {
      if (a[j] != b[i]) {
        cout << a[j] << endl;
        f = 1;
        break;
      }
    }
    if (f == 0) cout << a[n] << endl;
  }
  return 0;
}
