#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  int n;
  cin >> n;
  int maxx = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    maxx = max(maxx, a[i]);
  }
  for (int i = 0; i < n; i++) {
    if (a[i] < maxx)
      cout << maxx;
    else {
      int maxxx = -1;
      for (int j = 0; j < n; j++)
        if (j != i) maxxx = max(maxxx, a[j]);
      cout << maxxx;
    }
  }
  return 0;
}
