#include <bits/stdc++.h>
using namespace std;
const int inf = 1012345678;
int main() {
  long long n, x, mx;
  vector<long long> v, v2;
  cin >> n;
  for (long long i = long long(0); i <= long long(n - 1); i++) {
    cin >> x;
    v.push_back(x);
  }
  v2 = v;
  for (long long i = long long(0); i <= long long(n - 1); i++) {
    v[i] = 0;
    mx = *max_element(v.begin(), v.end());
    v[i] = v2[i];
    cout << mx << endl;
  }
}
