#include <bits/stdc++.h>
using namespace std;
void data() {}
const int N = 5e5 + 100;
const long long mod = 1e9 + 7;
int main() {
  data();
  int n;
  cin >> n;
  int a[n + 1];
  set<int> second;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    second.insert(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    set<int> q = second;
    q.erase(a[i]);
    cout << *q.rbegin() << '\n';
  }
}
