#include <bits/stdc++.h>
void MAX(int A[], int N) {
  int i;
  int max = A[0];
  for (i = 0; i < N; i++) {
    if (max < A[i]) max = A[i];
  }
  printf("%d\n", max);
}
int main(void) {
  int i;
  int N;
  int A[200000];
  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &A[i]);
  for (i = 0; i < N; i++) {
    int tmp = A[i];
    A[i] = 0;
    MAX(A, N);
    A[i] = tmp;
  }
}
