#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) cin >> data[i];
  for (int i = 0; i < N; i++) {
    vector<int> data2 = data;
    data2.erase(data2.begin() + i);
    sort(data2.begin(), data2.end());
    reverse(data2.begin(), data2.end());
    cout << data2[0] << endl;
  }
}
