#include "bits/stdc++.h" #define REP(i,n,N) for(int i=(n); i<(N); i++) #define RREP(i,n,N) for(int i=(N-1); i>=n; i--) #define CK(n,a,b) (a)<=(n)&&(n)<(b) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<>N>>M){ int a[1010]; vector edge[1010]; REP(i,0,N){ cin>>a[i]; } REP(i,0,M){ int u,v; cin>>u>>v; u--;v--; edge[u].push_back(v); //edge[v].push_back(u); } bool ok=false; REP(i,0,N){ for(auto e:edge[i]){ if(a[i]==a[e]) continue; for(auto v:edge[e]){ if(a[e]==a[v]||a[v]==a[i]) continue; if((a[i]a[e]&&a[e]>a[v])) continue; ok=true; } } } p(ok?"YES":"NO"); } return 0; }