#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t, r = 1, r1 = 0, r2 = 0, k = 0, a, b, c = 1, m, d = 0, n, e, f,
               x = 0, g, p = 0, q = 0, y = 0, z = 0;
  vector<long long> v;
  vector<long long> u;
  set<long long> s;
  std::vector<int>::iterator it;
  string s1, s2, s3, s4;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  for (int i = 0; i < n; i++) {
    x = v[i];
    v[i] = 0;
    y = *max_element(v.begin(), v.end());
    cout << y << endl;
    v[i] = x;
  }
}
