#include <bits/stdc++.h>
using namespace std;
int main(void) {
  vector<long> v;
  vector<long> V;
  long n, tmp;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    v.push_back(tmp);
  }
  V = v;
  for (int i = 0; i < n; i++) {
    v[i] = 0;
    cout << *max_element(v.begin(), v.end()) << endl;
    v = V;
  }
}
