For this Question: Newton has N different weights indexed from 1 to N i.e. W<sub>1</sub>, W<sub>2</sub>, ..., W<sub>N</sub>.
Newton is having a hard time trying to balance the weights. He wants to divide the weights into 2 parts. To do so, he is choosing an integer X and merging all the weights having an index not more than X into a single weight S<sub>1</sub> and the remaining weights into a single weight S<sub>2</sub>.
He needs to choose the index X in such a way that the absolute difference between the weights S<sub>1</sub> and S<sub>2</sub> is the minimum.
Find the least possible absolute difference that Newton can come up with.The first line of the input contains a single integer N.
The next line of the input contains N space-separated integers W<sub>1</sub>, W<sub>2</sub>, ... , W<sub>N</sub>.

<b>Constraints:</b>
1) 2 &le; N &le; 1000
2) 1 &le; W<sub>i</sub> &le; 1000Print the answer in a single line<b>Sample Input 1:</b>
4
1 2 3 6

<b>Sample Output 1:</b>
0

<b>Sample Input 2:</b>
4
1 3 1 1

<b>Sample Output 2:</b>
2

<b>Sample Input 3:</b>
8
27 23 76 2 3 5 62 52

<b>Sample Output 3:</b>
2

<b>Sample Explanation 1:</b>
Choose X as 3,
W<sub>1</sub> = 1 + 2 + 3 = 6
W<sub>2</sub> = 6
So, | W<sub>1</sub> - W<sub>2</sub> | = 0, I have written this Solution Code: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; //void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
#define repr(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
  
  int n;
  cin >> n;
  
  vector<int> w(n);
  rep(i, 0, n) cin >> w[i];
  
  int minn=10001;
  rep(i, 0, n){ //区切り位置
    int s1=0, s2=0;
    rep(j, 0, i) s1 += w[j];
    rep(j, i, n) s2 += w[j];
    minn = min(minn, abs(s1-s2));
    // cout << s1 << ' ' << s2 << ' ' << minn << endl;
  }
  
  cout << minn << endl;
                 
}
      
, In this Programming Language: C++, Now tell me if this Code is compilable or not?