#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;

int main(){
    int a,t=0,tt=0,ans=1e9;cin>>a;
    vector<int> v(a);
    for(auto &i:v) {cin>>i;t+=i;}
    for(auto i:v) {tt+=i;t-=i;ans=min(ans,abs(t-tt));}
    cout<<ans;
}