fork download
  1. program binaria;
  2.  
  3. const
  4. MAXN = 100000;
  5.  
  6. var
  7. A, B, N, i, row : int64;
  8. T : Array[0..MAXN-1] of int64;
  9.  
  10. begin
  11. {
  12.   uncomment the two following lines if you want to read/write from files
  13.   assign(input, 'input.txt'); reset(input);
  14.   assign(output, 'output.txt'); rewrite(output);
  15. }
  16.  
  17. ReadLn(N);
  18.  
  19. for i:=0 to N-1 do
  20. Read(T[i]);
  21. ReadLn();
  22.  
  23. B := 0;
  24.  
  25. for i:=0 to N-1 do
  26. begin
  27. A:=1; row:=A;
  28. while row<T[i] do begin A:=A shl 1; row:= row + A ; end;
  29. B:=B+row-T[i];
  30. end;
  31. WriteLn(B);
  32.  
  33. end.
  34.  
Success #stdin #stdout 0s 5280KB
stdin
2
10000000000000 1000000000000


stdout
7691697672190