#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, d, i, j, x = 0, cnt = 0;
  cin >> n;
  long long int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    cnt = 0;
    x = 0;
    for (j = 0; j < n; j++) {
      if (a[i] == a[j] && cnt == 0) {
        cnt++;
        continue;
      } else if (cnt == 0 || cnt == 1)
        x = max(x, a[j]);
    }
    cout << x << "\n";
  }
}
