#include <bits/stdc++.h>
using namespace std;
int cmp(int a, int b) { return a > b; }
int a[200010], ans[200010], n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    int tmp = a[i];
    int b[200010];
    memcpy(b, a, sizeof(a));
    b[i] = 0;
    sort(b + 1, b + n + 1, cmp);
    ans[i] = b[1];
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << endl;
  return 0;
}
