#include <bits/stdc++.h>
using namespace std;
inline int redi() {
  int ret = 0, f = 0;
  char ch = getchar_unlocked();
  while (!isdigit(ch)) {
    if (ch == '-') f = 1;
    ch = getchar_unlocked();
  }
  while (isdigit(ch)) {
    ret = ret * 10 + ch - 48;
    ch = getchar_unlocked();
  }
  return f ? -ret : ret;
}
inline void print(int x) {
  if (x < 0) {
    putchar_unlocked('-');
    x = -x;
  }
  int y = 10, len = 1;
  while (y <= x) {
    y *= 10;
    len++;
  }
  while (len--) {
    y /= 10;
    putchar_unlocked(x / y + 48);
    x %= y;
  }
}
inline void init() {
  long long int n, a, MAX[200000];
  memset(MAX, 0, sizeof(MAX));
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      MAX[j] = max(MAX[j], a);
    }
  }
  for (int i = 0; i < n; ++i) cout << MAX[i] << '\n';
}
inline void solve() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  init();
  solve();
  cout << flush;
  return 0;
}
