#include<iostream>
#include<cmath>
using namespace std;
int n,w[105],minn,k,g1,g2=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>w[i];
		g2+=w[i];
	}
	g1=0;
	minn=g2;
	for(int i=1;i<=n;i++){
		g1+=w[i];
		g2-=w[i];
		minn=min(minn,abs(g2-g1));
	}
	cout<<minn<<endl;
	return 0;
}