#include <bits/stdc++.h>
using namespace std;
int a, b;
int MAXX(vector<int> v, int k) {
  int max = 0;
  for (int i = (0); i < (k); ++i) {
    if (v[i] >= max) {
      max = v[i];
    }
  }
  return max;
}
int main() {
  int n, a, max;
  cin >> n;
  vector<int> v(n);
  for (int i = (0); i < (n); ++i) cin >> v[i];
  for (int i = (0); i < (n); ++i) {
    a = v[i];
    v[i] = 0;
    max = MAXX(v, n);
    cout << max << endl;
    v[i] = a;
  }
  return 0;
}
