#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 10];
  for (int i = 0; i < n; ++i) cin >> a[i];
  int ans = 0;
  for (int j = 0; j < n; ++j) {
    if (ans >= a[j]) continue;
    ans = 0;
    for (int k = 0; k < n; ++k) {
      if (j == k) continue;
      if (ans < a[k]) ans = a[k];
    }
    cout << ans << endl;
  }
}
