#include <iostream>
#include <set>
using namespace std;


int main() {
    
    set<int> s;
    
    int n;
    cin >> n;
    
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        
        s.insert(x);
    }
    
    int x;
    cin >> x;
    
    
    set<int>::iterator it = s.lower_bound(x);
    
    if(it != s.end()) {
        cout << *it << endl;
    }
    else {
        cout << "NEMA TAKOV BROJ" << endl;
    }
    
    
    return 0;
}
