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 max[] = new int[n];

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


        int min = 0;

        for (int i = 1; i < n; i++) {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        }
        System.out.println(min);

        sc.close();
    }
} 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 max[] = new int[n];

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


        int min = 0;

        for (int i = 1; i < n; i++) {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        }
        System.out.println(min);

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

        int n = sc.nextInt();

        int w[] = new int[n];

        int max[] = new int[n];

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


        int min = 0;

        for (int i = 1; i < n; i++) {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        }
        System.out.println(min);

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

        int n = sc.nextInt();

        int w[] = new int[n];

        int max[] = new int[n];

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


        int min = 0;

        for (int i = 1; i < n; i++) {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        }
        System.out.println(min);

        sc.close();
    } 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 max[] = new int[n]; max new int[n] n for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            w[i] = sc.nextInt();
        } {
            w[i] = sc.nextInt();
        } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc int min = 0; min 0 for (int i = 1; i < n; i++) {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        } {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        } int left = 0; left 0 int right = 0; right 0 for (int j = 0; j < i; j++) {
                left += w[j];
            } int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
                left += w[j];
            } {
                left += w[j];
            } left += w[j] left w[j] w j for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            } int k = 0; int k = 0; k 0 k < (n - i) k (n - i) n i k++ k++ k {
                right += w[i+k];
            } {
                right += w[i+k];
            } right += w[i+k] right w[i+k] w i+k i k if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            } (Math.abs(left-right) <= min) || min == 0 (Math.abs(left-right) <= min) Math.abs(left-right) Math.abs Math left-right left right min min == 0 min 0 {
                min = Math.abs(left-right);
            } min = Math.abs(left-right) min Math.abs(left-right) Math.abs Math left-right left right System.out.println(min) System.out.println System.out System System.out min sc.close() sc.close sc 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 max[] = new int[n];

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


        int min = 0;

        for (int i = 1; i < n; i++) {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        }
        System.out.println(min);

        sc.close();
    }
} 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 max[] = new int[n];

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


        int min = 0;

        for (int i = 1; i < n; i++) {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        }
        System.out.println(min);

        sc.close();
    }
} 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 max[] = new int[n];

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


        int min = 0;

        for (int i = 1; i < n; i++) {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        }
        System.out.println(min);

        sc.close();
    }
}