import java.util.Scanner; import java.math.BigInteger; public class Main { private static int [] a = new int[3005]; private static int T; private static int n; public static void solve() { BigInteger rs = BigInteger.ZERO; BigInteger temp = BigInteger.ONE; rs = rs.add(BigInteger.valueOf(a[n-1])); n--; for(int i=1, j=n; i<=n; i++, j--) { temp = temp.multiply(BigInteger.valueOf(j)).divide(BigInteger.valueOf(i)); temp = temp.multiply(BigInteger.valueOf(-1)); rs = rs.add(temp.multiply(BigInteger.valueOf(a[j-1]))); } System.out.println(rs); } public static void main(String[] args) { Scanner in = new Scanner(System.in); T = in.nextInt(); for(int i=0; i<T; i++) { n = in.nextInt(); for(int j=0; j<n; j++) { a[j] = in.nextInt(); } solve(); } } }