#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, tmp;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    tmp = a[i];
    a.erase(a.begin() + i);
    m = 0;
    for (int j = 0; j < a.size(); j++) {
      m = max(m, a[j]);
    }
    cout << m << endl;
    a.insert(a.begin() + i, tmp);
  }
  return 0;
}
