#include <bits/stdc++.h>
using namespace std;
long long a[200001];
int main() {
  ios_base ::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  multiset<long long> m;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
    m.insert(a[i]);
  }
  for (long long i = 1; i <= n; ++i) {
    m.erase(a[i]);
    cout << *m.rbegin() << "\n";
    m.insert(a[i]);
  }
  return 0;
}
