#include using namespace std; #define int long long #define ii pair #define app push_back #define all(a) a.begin(), a.end() #define bp __builtin_popcountll #define ll long long #define mp make_pair #define f first #define s second #define Time (double)clock()/CLOCKS_PER_SEC #define debug(x) std::cout << #x << ": " << x << '\n'; const int N = 1e5+7; vector g[N]; int sum[N], comp[N]; int a[N], d[N]; bool used[N]; void dfs(int u, int c) { used[u] = 1; comp[u] = c; sum[c] += d[u]; for (int v : g[u]) { if (!used[v]) { dfs(v, c); } } } signed main() { #ifdef HOME freopen("input.txt", "r", stdin); #else #define endl '\n' ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20); #endif int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { cin >> a[i]; if (i % 2 == 0) a[i] = -a[i]; d[i] = a[i] - a[i - 1]; //debug(d[i]); } while (m--) { int l, r; cin >> l >> r; g[r + 1].app(l); g[l].app(r + 1); } int ptr = 0; for (int i = 1; i <= n + 1; ++i) { if (!used[i]) { dfs(i, ptr); ptr++; } } for (int i = 0; i < ptr; ++i) { if (sum[i] != 0 && comp[n + 1] != i) { cout << "NO" << endl; exit(0); } } cout << "YES" << endl; }