#include using namespace std; int main(){ int N, M; cin >> N >> M; vector a(N); for (int i = 0; i < N; i++){ cin >> a[i]; } vector> E(N); for (int i = 0; i < M; i++){ int u, v; cin >> u >> v; u--; v--; E[u].push_back(v); E[v].push_back(u); } vector> st1(N), st2(N); for (int i = 0; i < N; i++){ for (int j : E[i]){ if (a[j] < a[i]){ st1[i].insert(a[j]); } if (a[j] > a[i]){ st2[i].insert(a[j]); } } } for (int i = 0; i < N; i++){ if (st1[i].size() >= 2 || st2[i].size() >= 2){ cout << "YES" << endl; return 0; } } cout << "NO" << endl; }