#include <bits/stdc++.h>
int main() {
  int r[20000];
  int n;
  int top, second;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &r[i]);
  }
  top = 0;
  second = 0;
  for (int i = 1; i < n; i++) {
    if (r[top] < r[i]) {
      second = top;
      top = i;
    }
  }
  for (int i = 0; i < n; i++) {
    if (top == i) {
      printf("%d", r[second]);
    } else {
      printf("%d", r[top]);
    }
    return 0;
  }
}
