#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1LL << 60;
const int inf = 1e9;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < (int)(N); i++) cin >> a[i];
  vector<int> cp(a);
  sort(cp.begin(), cp.end(), greater<int>());
  for (int i = 0; i < N; i++) {
    bool flag = false;
    for (int j = 0; j < N; j++) {
      if (a[i] != cp[j]) {
        cout << cp[j] << endl;
        flag = true;
        break;
      }
    }
    if (!flag) {
      cout << cp[0] << endl;
    }
  }
}
