#include <bits/stdc++.h>
using namespace std;
static const int INF = 1e+9 + 7;
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long i = (0); i < (N); ++i) {
    cin >> A[i];
  }
  for (long long i = (0); i < (N); ++i) {
    vector<long long> tmp = A;
    tmp.erase(tmp.begin() + i);
    cout << (*max_element((tmp).begin(), (tmp).end())) << "\n";
  }
  return 0;
}
