#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n;
  vector<int> vec(n);
  set<int> st;
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    st.insert(vec.at(i));
  }
  for (int i = 0; i < n; i++) {
    int max = 0;
    int x = vec.at(i);
    for (int j = 0; j < n; j++) {
      for (auto y : st) {
        if (x == y) continue;
        if (max < y) {
          max = y;
        }
      }
    }
    cout << max << endl;
  }
}
