#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> a_pre(N);
  for (int i = 0; i < int(N); ++i) {
    cin >> a[i];
    a_pre[i] = a[i];
  }
  for (int i = 0; i < int(N); ++i) {
    if (a_pre[i] == a[N - 1]) {
      cout << a[N - 2] << endl;
    } else {
      cout << a[N - 1] << endl;
    }
  }
}
