#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i, ans = 0, n, j, x, max;
  int kari = 0;
  vector<int> a;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
  for (i = 0; i < n; i++) {
    max = *max_element(a.begin(), a.end());
    if (a[i] == max) {
      for (j = 0; j < n; j++) {
        if (i != j and kari < a[j]) {
          kari = a[j];
        }
      }
      cout << kari << "\n";
      kari = 0;
    } else
      cout << max << "\n";
  }
}
