#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v1, v2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    v1.push_back(t);
  }
  v2 = v1;
  for (int i = 0; i < n; i++) {
    vector<int> v3;
    v3 = v1;
    v3.erase(v3.begin() + i);
    sort(v3.begin(), v3.end());
    cout << v3[v3.size() - 1] << endl;
  }
  return 0;
}
