#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, tmp = 0;
  cin >> n;
  vector<int> a(n);
  for (int& x : a) cin >> x;
  for (int i = 0; i < n; i++) {
    vector<int> T(a);
    a[i] = tmp;
    a.erase(a.begin() + i);
    sort(a.begin(), a.end());
    cout << a[a.size() - 1] << endl;
    a = T;
  }
}
