#include<stdio.h>
#include<algorithm>
using namespace std;
int a[1000000];
int main()
{
	int i, n, m, ans;
	while (~scanf("%d", &n))
	{
		ans = 200000000;
		a[0] = 0;
		for (i = 1; i <= n; i++)
		{
			scanf("%d", &m);
			a[i] = a[i - 1] + m;
		}
		for (i = 1; i<n; i++)ans = min(abs(a[i] * 2 - a[n]), ans);
		printf("%d\n", ans);
	}
}