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