fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long iint;
  4.  
  5. int main() {
  6. iint n;
  7. cin >> n;
  8. iint sum = (n * (n-1)) / 2;
  9. while (n > 1) {
  10. iint a;
  11. cin >> a;
  12. cout << a << endl;
  13. sum -= a;
  14. cout << "SUM " << sum << endl;
  15. n--;
  16. }
  17. cout << sum;
  18. }
Success #stdin #stdout 0.01s 5328KB
stdin
5
2 3 1 5
stdout
2
SUM 8
3
SUM 5
1
SUM 4
5
SUM -1
-1