#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int* a = new int[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    int ans = INT_MIN;
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      ans = max(ans, a[j]);
    }
    cout << ans << endl;
  }
  return 0;
}
