#include using namespace std; using ll = long long; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N >> M; vector A(N); FOR(i, 0, N){ cin >> A.at(i); } vector G[N]; FOR(i, 0, M){ ll u, v; cin >> u >> v; u--; v--; G[u].push_back(v); G[v].push_back(u); } FOR(i, 0, N){ ll center = A[i]; set up; set down; for(ll to : G[i]){ if(A[to]>center){ up.insert(A[to]); } else if(A[to]=2 || down.size()>=2){ p_yes(); return 0; } } p_no(); return 0; }