#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  int* a = new int[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    int t = a[i];
    a[i] = 0;
    cout << *max_element(a, a + n) << "\n";
    a[i] = t;
  }
  return 0;
}
