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