#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M; cin >> N >> M; vector a(N); rep(i,N) cin >> a[i]; vector> nt(N); rep(_,M) { int u,v; cin >> u >> v; u--; v--; nt[u].push_back(a[v]); nt[v].push_back(a[u]); } rep(v,N) { sort(nt[v].begin(), nt[v].end()); nt[v].erase(unique(nt[v].begin(), nt[v].end()), nt[v].end()); if(nt[v].size() >= 2u) { if(nt[v][1] < a[v] || a[v] < nt[v][int(nt[v].size()) - 1 - 1]) { cout << "YES" << endl; return 0; } } } cout << "NO" << endl; return 0; }