#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const unsigned long long base = 131;
const long long LL_MAX = 9223372036854775807;
using namespace std;
int b[200000];
vector<int> a, d;
int main() {
  int n;
  scanf("%d", &n);
  int x;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    a.push_back(x);
    d.push_back(x);
    b[x]++;
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (d[i] != a[n - 1])
      printf("%d\n", a[n - 1]);
    else {
      if (b[a[n - 1]] > 1)
        printf("%d\n", a[n - 1]);
      else
        printf("%d\n", *lower_bound(a.begin(), a.end(), a[n - 1] - 1));
    }
  }
  return 0;
}
