#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  vector<long long> num(n, 0);
  for (long long i = 0; i < (long long)(n); i++) cin >> num[i];
  for (long long i = 0; i < (long long)(n); i++) {
    long long x = num[i];
    num[i] = -1;
    cout << *max_element(num.begin(), num.end()) << endl;
    num[i] = x;
  }
}
