#include <bits/stdc++.h>
using namespace std;
int vmax(vector<int> v) {
  int a = v[0];
  for (int i = 0; i < (int)(v.size()); i++)
    if (v[i] > a) a = v[i];
  return a;
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  for (int i = 0; i < (int)(N); i++) {
    int k = A[i];
    A[i] = 0;
    cout << vmax(A) << endl;
    A[i] = k;
  }
}
