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