import java.io.BufferedInputStream; import java.util.*; public class Main { public static void main(String[] argv){ Scanner sc = new Scanner(System.in); int t= sc.nextInt(); while(t>0) { t--; long n = sc.nextLong(); long k = (n-2)*(n-1)*(2*n-3)/3 + (n -2 ) * (n-2); System.out.println(k); } } }