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