#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long(i) = 0; (i) < (n); (i)++) {
    cin >> a.at(i);
  }
  for (long long(i) = 0; (i) < (n); (i)++) {
    long long max = 0;
    for (long long(j) = 0; (j) < (n); (j)++) {
      if (i != j) {
        if (max < a[j]) {
          max = a[j];
        }
      }
    }
    cout << max << endl;
    ;
  }
  return 0;
}
