Sum[Sum[j - i, {j, i + 1, n}], {i, 1, n}]