#include<iostream>
using namespace std;
const int N=1e5+10;
int a[N],n;
int main(){
	cin>>n;
	int su=0;
	for(int i=0;i<n;i++) cin>>a[i],su+=a[i];
	int ans=su,f=0;
	for(int i=0;i<n;i++){
		f+=a[i];
		if(abs(su-2*f)<ans) ans=abs(su-2*f);
	}
	cout<<ans;
	return 0;
}
