#include <bits/stdc++.h>
using namespace std;
const long long INF = 1ll << 60;
long long MOD = 998244353;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) {
    int v = -1;
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      if (a[j] > v) v = a[j];
    }
    cout << v << endl;
  }
  return 0;
}
