#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    A.erase(A.begin() + i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  cout << A[1] << endl;
}
