long a[1<<18],*p=a+1;main(i){for(;~scanf("%d",a-i--)?:p-a-*p?i=*p,*p=a[i],a[i]=i,~--*a:*++p;);*a=!puts(*a&1?"NO":"YES");}