#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int in[n];
  set<int> st;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
    st.insert(in[i]);
  }
  for (int i = 0; i < n; i++) {
    int max = 0;
    int x = in[i];
    for (int j = 0; j < n; j++) {
      for (auto y = st.rbegin(), e = st.rend(); y != e; ++y) {
        if (x == *y) continue;
        if (max < *y) {
          max = *y;
        }
      }
    }
    cout << max << endl;
  }
}
