#include <bits/stdc++.h>
using namespace std;
template <class T>
bool minn(T &a, T b) {
  return (a > b ? (a = b, true) : false);
};
template <class T>
bool maxn(T &a, T b) {
  return (a < b ? (a = b, true) : false);
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  vector<int> arr1(n);
  int maxx = 0;
  int maxy = 0;
  for (int i = (0); i < (n); i++) cin >> arr1[i];
  vector<int> arr2((arr1).begin(), (arr1).end());
  maxx = arr2[0];
  maxy = arr2[1];
  for (int i = (0); i < (n); i++) {
    if (arr1[i] == arr2[0])
      cout << maxy << '\n';
    else
      cout << maxx << '\n';
  }
  return 0;
}
