import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n  = sc.nextInt();

        int[] w = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++) {
            w[i] = sc.nextInt();
            sum+=w[i];
        }

        int l = 0;
        int r = sum;

        int res = 1000000000;

        for(int i=0; i<n-1; i++) {
            l+=w[i];
            r-=w[i];
            res = Math.min(res, Math.abs(l-r));
        }

        System.out.println(res);

    }


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

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n  = sc.nextInt();

        int[] w = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++) {
            w[i] = sc.nextInt();
            sum+=w[i];
        }

        int l = 0;
        int r = sum;

        int res = 1000000000;

        for(int i=0; i<n-1; i++) {
            l+=w[i];
            r-=w[i];
            res = Math.min(res, Math.abs(l-r));
        }

        System.out.println(res);

    }


} Main public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n  = sc.nextInt();

        int[] w = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++) {
            w[i] = sc.nextInt();
            sum+=w[i];
        }

        int l = 0;
        int r = sum;

        int res = 1000000000;

        for(int i=0; i<n-1; i++) {
            l+=w[i];
            r-=w[i];
            res = Math.min(res, Math.abs(l-r));
        }

        System.out.println(res);

    } main {

        Scanner sc = new Scanner(System.in);

        int n  = sc.nextInt();

        int[] w = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++) {
            w[i] = sc.nextInt();
            sum+=w[i];
        }

        int l = 0;
        int r = sum;

        int res = 1000000000;

        for(int i=0; i<n-1; i++) {
            l+=w[i];
            r-=w[i];
            res = Math.min(res, Math.abs(l-r));
        }

        System.out.println(res);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n  = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] w = new int[n]; w new int[n] n int sum = 0; sum 0 for(int i=0; i<n; i++) {
            w[i] = sc.nextInt();
            sum+=w[i];
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            w[i] = sc.nextInt();
            sum+=w[i];
        } {
            w[i] = sc.nextInt();
            sum+=w[i];
        } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc sum+=w[i] sum w[i] w i int l = 0; l 0 int r = sum; r sum int res = 1000000000; res 1000000000 for(int i=0; i<n-1; i++) {
            l+=w[i];
            r-=w[i];
            res = Math.min(res, Math.abs(l-r));
        } int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
            l+=w[i];
            r-=w[i];
            res = Math.min(res, Math.abs(l-r));
        } {
            l+=w[i];
            r-=w[i];
            res = Math.min(res, Math.abs(l-r));
        } l+=w[i] l w[i] w i r-=w[i] r w[i] w i res = Math.min(res, Math.abs(l-r)) res Math.min(res, Math.abs(l-r)) Math.min Math res Math.abs(l-r) Math.abs Math l-r l r System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n  = sc.nextInt();

        int[] w = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++) {
            w[i] = sc.nextInt();
            sum+=w[i];
        }

        int l = 0;
        int r = sum;

        int res = 1000000000;

        for(int i=0; i<n-1; i++) {
            l+=w[i];
            r-=w[i];
            res = Math.min(res, Math.abs(l-r));
        }

        System.out.println(res);

    }


} public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n  = sc.nextInt();

        int[] w = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++) {
            w[i] = sc.nextInt();
            sum+=w[i];
        }

        int l = 0;
        int r = sum;

        int res = 1000000000;

        for(int i=0; i<n-1; i++) {
            l+=w[i];
            r-=w[i];
            res = Math.min(res, Math.abs(l-r));
        }

        System.out.println(res);

    }


} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n  = sc.nextInt();

        int[] w = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++) {
            w[i] = sc.nextInt();
            sum+=w[i];
        }

        int l = 0;
        int r = sum;

        int res = 1000000000;

        for(int i=0; i<n-1; i++) {
            l+=w[i];
            r-=w[i];
            res = Math.min(res, Math.abs(l-r));
        }

        System.out.println(res);

    }


}
