// you can use includes, for example: // #include <algorithm>
// you can write to stdout for debugging purposes, e.g. // cout << "this is a debug message" << endl;
intsolution(vector<int> &A){ // write your code in C++14 (g++ 6.2.0) int total = 0, ret = 100000, n = A.size(), sum = 0; for(int a:A) total +=a; for(int i=0;i<n-1;++i) { sum+=A[i]; ret = min(ret, abs(total-2*sum) ); } return ret; }