eval'N,*A='+$<.read.split*?, (1..2*N-4).map{|i|(0..i).map{|a|a,b=[a,i-a].sort;b>N-1&&break;A[a]>(c=A[b])&&(A[b]=A[a];A[a]=c)}} $><