#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> num;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    num.push_back(temp);
  }
  sort(num.begin(), num.end(), greater<int>());
  auto last = unique(num.begin(), num.end());
  num.erase(last, num.end());
  num.pop_back();
  if (!num.empty()) {
    cout << num.back();
  } else {
    cout << "NO";
  }
}
