fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception{
  10. Scanner in = new Scanner(System.in);
  11. int n = in.nextInt();
  12. int[] a = new int[n];
  13. for(int i=0;i<n;i++){
  14. a[i]= in.nextInt();
  15. }
  16. int S=0;
  17. int i;
  18. for(i=0;i<n;i++){
  19. for(int j=0;j<n-i-1;j++){
  20. S+=a[j];
  21. }
  22. a[n-i-1]=S;
  23. S=0;
  24. }
  25. a[0]=a[1];
  26. for( i=0;i<n;i++){
  27. System.out.print(a[i]+" ");
  28. }
  29. }
  30. }
Success #stdin #stdout 0.06s 711680KB
stdin
6 1 1 1 1 1 1 1
stdout
1 1 2 3 4 5