#include <bits/stdc++.h>
using namespace std;
int mod = INT_MAX;
vector<int> mp;
int main() {
  int n;
  cin >> n;
  for (int x = 0; x < n; x++) {
    int a;
    cin >> a;
    mp.push_back(a);
  }
  for (int x = 0; x < n; x++) {
    int mx = -mod;
    for (int y = 0; y < n; y++) {
      if (y != x) {
        if (mp[y] > mx) {
          mx = mp[y];
        }
      }
    }
    cout << mx << endl;
  }
}
