#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, num;
  cin >> n;
  vector<int> arr, brr;
  for (long long i = (0); i < (n); ++i) {
    cin >> num;
    arr.push_back(num);
  }
  for (long long i = (0); i < (n); ++i) {
    brr = arr;
    if (n > 0) {
      brr.erase(remove(brr.begin(), brr.end(), brr[i]));
      sort((brr).begin(), (brr).end());
      cout << brr[n - 2] << "\n";
    } else
      cout << brr[i];
  }
}
