#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<int> v,v2;
	int n,a;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf("%d",&a);
		v2.push_back(a);
		if(i == 0){
			v.push_back(a);
		}else{
			v.push_back(v[i-1]+a);
		}
	}
	
	for (int i = v2.size()-2; i >= 0; i--){
		v2[i]=v2[i]+v2[i+1];
	}
	int minimo = INT_MAX;

	for (int i = 0; i < v.size(); ++i){
		minimo = min(minimo,abs(v[i]-v2[i+1]));
	}
	cout<<minimo<<'\n';
	return 0;
}