#include <stdio.h>
#include <math.h>
#define MAXN 200005
#define INF 0x3f3f3f3f

int main()
{
    int n;
    while(scanf("%d", &n) != EOF)
    {
        int a, num_s = 0, num = n;
        int sum[MAXN];
        while(num--)
        {
            scanf("%d", &a);
            if(num_s == 0)sum[num_s] = a;
            else
                sum[num_s] =sum[num_s - 1] + a;
            num_s++;
        }
        int min = INF;
        for(int i = 0; i < num_s - 1; i++)
        {
            int cha = fabs(sum[num_s - 1] - 2 * sum[i]);
            min = (min < cha) ? min : cha;
        }
        printf("%d\n", min);
    }
    return 0;
}
