#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
  int n, ans = 0, flag = 0;
  cin >> n;
  int a[n + 1], f[200001] = {0}, ii = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ii++;
    f[ii] = a[i];
  }
  sort(f + 1, f + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    flag = 0;
    for (int j = 1; j <= ii; j++) {
      if (a[i] != f[j]) {
        flag = 1;
        cout << f[j] << endl;
        break;
      }
    }
    if (flag == 0) cout << a[1] << endl;
  }
  return 0;
}
