#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000 + 10;
int n, a[MAXN], b[MAXN];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int j = 1; j <= n; j++)
      if (j != i) b[++cnt] = a[j];
    sort(b + 1, b + cnt + 1);
    cout << b[cnt] << endl;
  }
  return 0;
}
