h=1000000 mem=[0]*(h) (2...h).reduce(0){|t, i| mem[i] = t + i * i - i} gets.to_i.times do p mem[gets.to_i-1]*2 end