#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    int tmp = a[i];
    a[i] = 0;
    printf("%d\n", *max_element(a.begin(), a.end()));
    a[i] = tmp;
  }
  return 0;
}
