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