from scipy.special import perm from itertools import accumulate T = int(input()) qs = [int(input()) for _ in range(T)] mq = max(qs) s = [] for j in range(3, mq+1): p = perm(j-1, 2, exact=True) s.append(p*2) accum_s = list(accumulate(s)) for q in qs: print(accum_s[q-3])