#include <bits/stdc++.h>
int main(void) {
  int n;
  scanf("%d", &n);
  int a[200000];
  int i;
  int j;
  int ans;
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= n; ++j) {
    start:
      ans = 0;
      if (j == i) {
        ++j;
        goto start;
      }
      if (a[j] >= ans) {
        ans = a[j];
      }
    }
    scanf("%d\n", ans);
  }
  return 0;
}
