#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> A(n);
  for (long long i = 0; i < n; i++) {
    cin >> A.at(i);
  }
  long long max = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (i == j) {
        continue;
      }
      if (max < A.at(j)) {
        max = A.at(j);
      }
    }
    cout << max << endl;
    max = 0;
  }
}
