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