#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
const long long INF = numeric_limits<long long>::max();
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < (N); i++) {
    cin >> A[i];
  }
  for (int i = 0; i < (N); i++) {
    if ((i + 1) == distance(A.begin(), max_element(begin(A), end(A)))) {
      cout << *max_element(begin(A), end(A)) << endl;
      continue;
    }
    vector<int> B = A;
    B.erase(B.begin() + i);
    cout << *max_element(begin(B), end(B)) << endl;
  }
}
