#include <bits/stdc++.h>
using namespace std;
long long Pow_mod(long long a, long long b, long long c) {
  long long ans = 1;
  a %= c;
  while (b) {
    if (b & 1) ans = (ans * a) % c;
    a = (a * a) % c;
    b >>= 1;
  }
  return (ans % c);
}
int a[200010];
int find_max(int n, int pos, int *x) {
  int max_ = 0;
  for (int i = 1; i <= n; i++) {
    if (i == pos) continue;
    if (x[i] > max_) max_ = x[i];
  }
  return max_;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) printf("%d\n", find_max(n, i, a));
  return 0;
}
