#include <bits/stdc++.h>
using namespace std;
void vout(vector<long long int> v) {
  for (long long int i = 0; i < v.size(); i++) cout << v.at(i) << endl;
}
int main() {
  cout << std::fixed << std::setprecision(10);
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  for (int i = 0; i < (int)(n); i++) {
    long long int rec = a[i];
    a[i] = -1;
    cout << *max_element(a.begin(), a.end()) << endl;
    ;
    a[i] = rec;
  }
}
