#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
struct edge {
  int myc, to, c, cost;
};
struct pos {
  int to, cost, color;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int main() {
  int n;
  int a[n];
  int b[n];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    if (b[i] == a[n - 1]) {
      cout << a[n - 2] << endl;
    } else {
      cout << a[n - 1] << endl;
    }
  }
  return 0;
}
