#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a, b;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
    b.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    b[i] = 0;
    for (int j = 0; j < n; j++) {
      if (b[i] < a[j] && (i != j)) b[i] = a[j];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << b[i] << endl;
  }
}
