#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e+14;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
void Yes() {
  cout << "Yes" << endl;
  exit(0);
}
void No() {
  cout << "No" << endl;
  exit(0);
}
int main() {
  long long N;
  cin >> N;
  vector<long long> A(200010);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<long long> B(200010);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j)
        B[j] = 0;
      else
        B[j] = A[j];
    }
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    cout << B[0] << endl;
  }
}
