import java.math.BigInteger;
import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
int a[] = new int[3005];
for (int cas = 1; cas <= t; cas++) {
int n = in.nextInt();
int i, j;
for (i = 1; i <= n; ++i) {
a[i] = in.nextInt();
}
BigInteger ans = BigInteger.valueOf(a[n]);
BigInteger x = BigInteger.valueOf(1);
BigInteger flag = BigInteger.valueOf(-1);
n = n -1;
for(i=1,j=n; i<=n; i++,j--)
{
x = x.multiply(BigInteger.valueOf(j)).divide(BigInteger.valueOf(i));
x = x.multiply(flag);
ans = ans.add(x.multiply(BigInteger.valueOf(a[j])));
}
System.out.println(ans);
}
}
}
tjut 4927
最新推荐文章于 2018-11-19 12:04:00 发布