#include <bits/stdc++.h>
using namespace std;
int n, a[200010], b[200010];
bool cmp(const int &a1, const int &a2) { return a1 >= a2; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++)
    if (b[i] == a[1])
      printf("%d\n", a[2]);
    else
      printf("%d\n", a[1]);
  return 0;
}
