import java.util.Scanner;
import java.util.Arrays;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] balls = new int[NUM];
        int sum = 0;
        for(int i = 0; i < NUM; i++){
            balls[i] = scan.nextInt();
            sum += balls[i];
        }

        // search
        int halfSum = 0;
        int answer = Integer.MAX_VALUE;
        for(int i = 0; i < NUM-1; i++){
            halfSum += balls[i];
            if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            }
        }

        // answer
        System.out.println(answer);

    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] balls = new int[NUM];
        int sum = 0;
        for(int i = 0; i < NUM; i++){
            balls[i] = scan.nextInt();
            sum += balls[i];
        }

        // search
        int halfSum = 0;
        int answer = Integer.MAX_VALUE;
        for(int i = 0; i < NUM-1; i++){
            halfSum += balls[i];
            if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            }
        }

        // answer
        System.out.println(answer);

    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] balls = new int[NUM];
        int sum = 0;
        for(int i = 0; i < NUM; i++){
            balls[i] = scan.nextInt();
            sum += balls[i];
        }

        // search
        int halfSum = 0;
        int answer = Integer.MAX_VALUE;
        for(int i = 0; i < NUM-1; i++){
            halfSum += balls[i];
            if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            }
        }

        // answer
        System.out.println(answer);

    } main {
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] balls = new int[NUM];
        int sum = 0;
        for(int i = 0; i < NUM; i++){
            balls[i] = scan.nextInt();
            sum += balls[i];
        }

        // search
        int halfSum = 0;
        int answer = Integer.MAX_VALUE;
        for(int i = 0; i < NUM-1; i++){
            halfSum += balls[i];
            if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            }
        }

        // answer
        System.out.println(answer);

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) final int NUM = scan.nextInt(); NUM scan.nextInt() scan.nextInt scan int[] balls = new int[NUM]; balls new int[NUM] NUM int sum = 0; sum 0 for(int i = 0; i < NUM; i++){
            balls[i] = scan.nextInt();
            sum += balls[i];
        } int i = 0; int i = 0; i 0 i < NUM i NUM i++ i++ i {
            balls[i] = scan.nextInt();
            sum += balls[i];
        } {
            balls[i] = scan.nextInt();
            sum += balls[i];
        } balls[i] = scan.nextInt() balls[i] balls i scan.nextInt() scan.nextInt scan sum += balls[i] sum balls[i] balls i int halfSum = 0; halfSum 0 int answer = Integer.MAX_VALUE; answer Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 0; i < NUM-1; i++){
            halfSum += balls[i];
            if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            }
        } int i = 0; int i = 0; i 0 i < NUM-1 i NUM-1 NUM 1 i++ i++ i {
            halfSum += balls[i];
            if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            }
        } {
            halfSum += balls[i];
            if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            }
        } halfSum += balls[i] halfSum balls[i] balls i if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            } Math.abs((sum - halfSum) - halfSum) < answer Math.abs((sum - halfSum) - halfSum) Math.abs Math (sum - halfSum) - halfSum (sum - halfSum) sum halfSum halfSum answer {
                answer = Math.abs((sum - halfSum) - halfSum);
            } answer = Math.abs((sum - halfSum) - halfSum) answer Math.abs((sum - halfSum) - halfSum) Math.abs Math (sum - halfSum) - halfSum (sum - halfSum) sum halfSum halfSum System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] balls = new int[NUM];
        int sum = 0;
        for(int i = 0; i < NUM; i++){
            balls[i] = scan.nextInt();
            sum += balls[i];
        }

        // search
        int halfSum = 0;
        int answer = Integer.MAX_VALUE;
        for(int i = 0; i < NUM-1; i++){
            halfSum += balls[i];
            if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            }
        }

        // answer
        System.out.println(answer);

    }
} public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] balls = new int[NUM];
        int sum = 0;
        for(int i = 0; i < NUM; i++){
            balls[i] = scan.nextInt();
            sum += balls[i];
        }

        // search
        int halfSum = 0;
        int answer = Integer.MAX_VALUE;
        for(int i = 0; i < NUM-1; i++){
            halfSum += balls[i];
            if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            }
        }

        // answer
        System.out.println(answer);

    }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] balls = new int[NUM];
        int sum = 0;
        for(int i = 0; i < NUM; i++){
            balls[i] = scan.nextInt();
            sum += balls[i];
        }

        // search
        int halfSum = 0;
        int answer = Integer.MAX_VALUE;
        for(int i = 0; i < NUM-1; i++){
            halfSum += balls[i];
            if(Math.abs((sum - halfSum) - halfSum) < answer){
                answer = Math.abs((sum - halfSum) - halfSum);
            }
        }

        // answer
        System.out.println(answer);

    }
}