#include #define R(n) for(I i=0;i<(n);i++) using std::cin; using I=long long; I v[1<<18],A[1<<18]={},s[1<<18]={},n,q,y=1,a,b; I r(I a){return v[a]-a?v[a]=r(v[a]):a;} int main(){ cin>>n>>q; R(n){cin>>A[i];if(i&1)A[i]*=-1;} n++;R(n){A[n-i]-=A[n-i-1];v[i]=i;} R(q){cin>>a>>b;v[r(--a)]=r(b);} R(n)s[r(i)]+=A[i]; R(n)if(s[i])y=0; printf(y?"YES\n":"NO\n"); return 0; }