#include<bits/stdc++.h>
using namespace std;
int n,a[110],ans=1e9;
int main(){
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++){
		int sum=0,num=0;
		for (int j=1;j<=i;j++) sum+=a[j];
		for (int j=i+1;j<=n;j++) num+=a[j];
		ans=min(ans,abs(sum-num));
	}
	cout<<ans<<endl;
	return 0;
}