#include <bits/stdc++.h>
using namespace std;
int a[200010];
int b[200010];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    b[i] = 0;
    for (int j = 0; j < n; ++j) {
      if (j == i) continue;
      if (b[i] < a[j]) b[i] = a[j];
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << b[i] << endl;
  }
  return 0;
}
