#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int M = 0;
  cin >> N;
  vector<int> vec(N);
  for (int X = 0; X < N; X++) {
    cin >> vec.at(X);
  }
  for (int X = 0; X < N; X++) {
    M = 0;
    for (int Y = 0; Y < N; Y++) {
      if (Y == X) {
        continue;
      } else if (M < vec.at(Y)) {
        M = vec.at(Y);
      }
    }
    cout << M << endl;
  }
}
