#include using namespace std; typedef long long ll; typedef pair l_l; typedef pair i_i; template inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } const long long INF = 1e18; //const ll mod = 1000000007; ll N, M; ll B[100500]; vector C; ll L[105000], R[105000]; vector query[105000]; void merge(vector &a, vector &b) { if(a.size() < b.size()) swap(a, b); for(auto tmp : b) { a.push_back(tmp); } b.clear(); } void print(vector v) { cerr << "{"; for(int i = 0; i < v.size(); i++) { if(i != 0) cerr << ", "; cerr << v[i]; } cerr << "}" << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; for(int i = 1; i <= N; i++) cin >> B[i]; C.resize(N + 1); for(int i = 0; i <= N; i++) { C[i] = B[i] + B[i+1]; } N++; for(int i = 0; i < M; i++) { cin >> L[i] >> R[i]; L[i]--; query[L[i]].push_back(R[i]); } //print(C); for(int i = 0; i < N; i++) { //cerr << "---" << i << "---" << endl; if(query[i].empty()) continue; sort(query[i].begin(), query[i].end()); query[i].erase(unique(query[i].begin(), query[i].end()), query[i].end()); //print(query[i]); ll r = query[i][0]; if(r == i) { C[i] = 0; } else if((r - i) % 2 == 0) { ll delta = C[i]; C[i] -= delta; C[r] += delta; } else { ll delta = C[i]; C[i] -= delta; C[r] -= delta; } query[i].erase(query[i].begin()); merge(query[r], query[i]); } //print(C); string ans = "YES"; for(int i = 0; i < N; i++) { if(C[i] != 0) { ans = "NO"; } } cout << ans << endl; return 0; }