#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n, arr[1000000];
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  for (unsigned long long i = 0; i < n; ++i) {
    unsigned long long x = i, min = 0;
    for (unsigned long long i = 0; i < n; ++i) {
      if (arr[i] > min && i != x) min = arr[i];
    }
    cout << min << endl;
  }
  return 0;
}
