#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool amax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool amin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int32_t GCD(int32_t a, int32_t b) { return b ? GCD(b, a % b) : a; }
int64_t GCD(int64_t a, int64_t b) { return b ? GCD(b, a % b) : a; }
int32_t LCM(int32_t a, int32_t b) { return a * b / GCD(a, b); }
int64_t LCM(int64_t a, int64_t b) { return a * b / GCD(a, b); }
struct aaa {
  aaa() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} aaaaaaa;
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7;
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = {1, 1, 0, -1, -1, -1, 0, 1},
                  dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];
  vector<int> b(n);
  for (int i = 0, i_len = (int)n; i < i_len; ++i) b[i] = a[i];
  for (int i = 0, i_len = (int)n; i < i_len; ++i) {
    if (b[n - 1] == a[i]) {
      cout << b[n - 2] << '\n';
    } else {
      cout << b[n - 1] << '\n';
    }
  }
}
