n = int(eval(input()))

print((n*(n-1)//2))
n = int(eval(input()))

ans = (n-1)*n//2

print(ans)
n = int(eval(input()))
print((n * (n - 1) // 2))

n = int(eval(input()))
ans = (n - 1) * n // 2
print(ans)

-print((n * (n - 1) // 2)) +ans = (n - 1) * n // 2 +print(ans)