T = gets.to_i memo = Array.new(1_000_010, 0) 3.upto(1_000_010) do |n| memo[n] = memo[n - 1] + (n - 1) * (n - 2) end T.times do n = gets.to_i puts 2 * memo[n] end