#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  vector<int> B(n);
  vector<int> C(n);
  int max = -1;
  int pos = -1;
  for (int i = 0; i < n; i++) {
    B = A;
    B[i] = 0;
    sort(B.begin(), B.end(), greater<int>());
    C[i] = B[0];
  }
  for (int i = 0; i < n; i++) {
    cout << C[i] << endl;
  }
}
