sum(sum(max(i,j),i=1..n),j=1..n)