#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
const float PI = 3.14;
typedef map<string, int> msi;
typedef vector<pair<int, int> > vii;
typedef priority_queue<pair<int, int>, vector<pair<int, int> >,
                       greater<pair<int, int> > >
    pq;
vector<pair<int, int> >::iterator iter;
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int tab[1000005];
  for (int i = 0; i < n; i++) {
    cin >> tab[i];
  }
  int maxi;
  for (int i = 0; i < n; i++) {
    maxi = 0;
    for (int j = 0; j < n; j++) {
      if (i != j) {
        if ((tab[j] > maxi) && (tab[j] != tab[i])) {
          maxi = tab[j];
        }
      }
    }
    cout << maxi << "\n";
  }
  return 0;
}
