#include <bits/stdc++.h>
using namespace std;
const int N = 10000000;
int a[N];
int main() {
  int n;
  int maxn = -2e9;
  int minn = 2e9;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    a[x + 100]++;
    maxn = max(maxn, x + 100);
    minn = min(minn, x + 100);
  }
  int sum = 0;
  for (int i = minn; i <= maxn; i++) {
    if (a[i] > 0) {
      sum++;
    }
    if (sum == 2) {
      cout << i - 100;
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
