#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n), B(n);
  int maxx = 0, pos = 0;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(B.begin(), B.end());
  for (int i = 1; i <= n; i++) {
    if (A[i] != B[n])
      cout << B[n];
    else
      cout << B[n - 1];
  }
  return 0;
}
