fork download
  1. import java.io.*;
  2. import java.util.*;
  3. class Main
  4. {
  5. public static void main(String args[])throws IOException
  6. {
  7. int i=1;
  8. int bal=0,j,k,n;
  9. Scanner s=new Scanner(System.in);
  10. int t=s.nextInt();
  11. for(i=1;i<=t;i++)
  12. {
  13. n=s.nextInt();
  14. int arr[]=new int[100000];
  15. for(j=1;j<=n;j++)
  16. arr[j]=s.nextInt();
  17. for(j=1;j<=n;j++)
  18. {
  19.  
  20. bal=0;
  21. for(k=1;k<j;k++)
  22. bal=bal+arr[j]-arr[k];
  23. System.out.print(bal);
  24. }
  25. }
  26. }
  27. }
  28.  
  29.  
  30.  
Success #stdin #stdout 0.06s 4386816KB
stdin
2
3
2 1 3
4
1 2 2 3
stdout
0-130114