#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b[10000], c[10000], d;
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> b[i];
    b[i] = c[i];
  }
  sort(c, c + a - 1, greater<int>());
  for (int i = 0; i < a; i++) {
    if (b[i] == c[0]) {
      cout << c[1];
    } else
      cout << c[0];
  }
}
