#include <bits/stdc++.h>
using namespace std;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  int max = 0;
  for (int i = 0; i < (n); i++) {
    cin >> vec[i];
    if (vec[i] >= max) max = vec[i];
  }
  for (int i = 0; i < n; i++) {
    if (vec[i] < max) {
      cout << max << endl;
      continue;
    } else {
      int tmp_max = 0;
      for (int j = 0; j < n; j++) {
        if (j == i) {
          continue;
        } else {
          if (max >= vec[j]) {
            tmp_max = vec[j];
          }
        }
      }
      cout << tmp_max << endl;
    }
  }
  return 0;
}
