import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] wei = new int[num];
        int[] ans = new int[num-1];
        int sum = 0;
        int t = 0;

        for(int i = 0;i < num;i++){
            wei[i] = sc.nextInt();
            sum += wei[i];
        }
        
        for(int i = 0;i < num-1;i++){
            int s1 = 0;
            for(int j = 0;j <= t;j++){
                s1 += wei[j];
            }
            ans[i] = Math.abs(sum-(2*s1));
            t++;
        }
        Arrays.sort(ans);
        System.out.println(ans[0]);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] wei = new int[num];
        int[] ans = new int[num-1];
        int sum = 0;
        int t = 0;

        for(int i = 0;i < num;i++){
            wei[i] = sc.nextInt();
            sum += wei[i];
        }
        
        for(int i = 0;i < num-1;i++){
            int s1 = 0;
            for(int j = 0;j <= t;j++){
                s1 += wei[j];
            }
            ans[i] = Math.abs(sum-(2*s1));
            t++;
        }
        Arrays.sort(ans);
        System.out.println(ans[0]);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] wei = new int[num];
        int[] ans = new int[num-1];
        int sum = 0;
        int t = 0;

        for(int i = 0;i < num;i++){
            wei[i] = sc.nextInt();
            sum += wei[i];
        }
        
        for(int i = 0;i < num-1;i++){
            int s1 = 0;
            for(int j = 0;j <= t;j++){
                s1 += wei[j];
            }
            ans[i] = Math.abs(sum-(2*s1));
            t++;
        }
        Arrays.sort(ans);
        System.out.println(ans[0]);
    } main {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] wei = new int[num];
        int[] ans = new int[num-1];
        int sum = 0;
        int t = 0;

        for(int i = 0;i < num;i++){
            wei[i] = sc.nextInt();
            sum += wei[i];
        }
        
        for(int i = 0;i < num-1;i++){
            int s1 = 0;
            for(int j = 0;j <= t;j++){
                s1 += wei[j];
            }
            ans[i] = Math.abs(sum-(2*s1));
            t++;
        }
        Arrays.sort(ans);
        System.out.println(ans[0]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc int[] wei = new int[num]; wei new int[num] num int[] ans = new int[num-1]; ans new int[num-1] num-1 num 1 int sum = 0; sum 0 int t = 0; t 0 for(int i = 0;i < num;i++){
            wei[i] = sc.nextInt();
            sum += wei[i];
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
            wei[i] = sc.nextInt();
            sum += wei[i];
        } {
            wei[i] = sc.nextInt();
            sum += wei[i];
        } wei[i] = sc.nextInt() wei[i] wei i sc.nextInt() sc.nextInt sc sum += wei[i] sum wei[i] wei i for(int i = 0;i < num-1;i++){
            int s1 = 0;
            for(int j = 0;j <= t;j++){
                s1 += wei[j];
            }
            ans[i] = Math.abs(sum-(2*s1));
            t++;
        } int i = 0; int i = 0; i 0 i < num-1 i num-1 num 1 i++ i++ i {
            int s1 = 0;
            for(int j = 0;j <= t;j++){
                s1 += wei[j];
            }
            ans[i] = Math.abs(sum-(2*s1));
            t++;
        } {
            int s1 = 0;
            for(int j = 0;j <= t;j++){
                s1 += wei[j];
            }
            ans[i] = Math.abs(sum-(2*s1));
            t++;
        } int s1 = 0; s1 0 for(int j = 0;j <= t;j++){
                s1 += wei[j];
            } int j = 0; int j = 0; j 0 j <= t j t j++ j++ j {
                s1 += wei[j];
            } {
                s1 += wei[j];
            } s1 += wei[j] s1 wei[j] wei j ans[i] = Math.abs(sum-(2*s1)) ans[i] ans i Math.abs(sum-(2*s1)) Math.abs Math sum-(2*s1) sum (2*s1) 2 s1 t++ t Arrays.sort(ans) Arrays.sort Arrays ans System.out.println(ans[0]) System.out.println System.out System System.out ans[0] ans 0 String[] args args
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] wei = new int[num];
        int[] ans = new int[num-1];
        int sum = 0;
        int t = 0;

        for(int i = 0;i < num;i++){
            wei[i] = sc.nextInt();
            sum += wei[i];
        }
        
        for(int i = 0;i < num-1;i++){
            int s1 = 0;
            for(int j = 0;j <= t;j++){
                s1 += wei[j];
            }
            ans[i] = Math.abs(sum-(2*s1));
            t++;
        }
        Arrays.sort(ans);
        System.out.println(ans[0]);
    }
}