#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int srs[n];
  for (int i = 0; i < n; i++) {
    cin >> srs[i];
  }
  sort(srs, srs + n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (srs[i] == srs[i + 1]) {
      count++;
    }
  }
  int dist, min = INT_MAX;
  if (count >= 1)
    cout << n << endl;
  else {
    dist = 0;
    for (int i = 0; i < n; i++) {
      dist = srs[i] - srs[i - 1];
      if (min > dist) {
        min = dist;
      }
    }
  }
  cout << srs[n - min] << endl;
  return 0;
}
