import java.util.*;
import java.lang.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] weight = new int[N];
        int sum =0;
        int sum2 = 0;
        int[] g = new int[N];
        for(int j =0; j < N ; j++){
            weight[j] = sc.nextInt();

        }
        for(int t =1; t <= N; t ++) {
            for (int i = 1; i <= N; i++) {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            }
            g[t-1] = Math.abs(sum - sum2);
            sum =0;
            sum2 =0;
        }
        Arrays.sort(g);
        System.out.println(g[0]);
    }
} import java.util.*; util.* java import java.lang.*; lang.* java class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] weight = new int[N];
        int sum =0;
        int sum2 = 0;
        int[] g = new int[N];
        for(int j =0; j < N ; j++){
            weight[j] = sc.nextInt();

        }
        for(int t =1; t <= N; t ++) {
            for (int i = 1; i <= N; i++) {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            }
            g[t-1] = Math.abs(sum - sum2);
            sum =0;
            sum2 =0;
        }
        Arrays.sort(g);
        System.out.println(g[0]);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] weight = new int[N];
        int sum =0;
        int sum2 = 0;
        int[] g = new int[N];
        for(int j =0; j < N ; j++){
            weight[j] = sc.nextInt();

        }
        for(int t =1; t <= N; t ++) {
            for (int i = 1; i <= N; i++) {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            }
            g[t-1] = Math.abs(sum - sum2);
            sum =0;
            sum2 =0;
        }
        Arrays.sort(g);
        System.out.println(g[0]);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] weight = new int[N];
        int sum =0;
        int sum2 = 0;
        int[] g = new int[N];
        for(int j =0; j < N ; j++){
            weight[j] = sc.nextInt();

        }
        for(int t =1; t <= N; t ++) {
            for (int i = 1; i <= N; i++) {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            }
            g[t-1] = Math.abs(sum - sum2);
            sum =0;
            sum2 =0;
        }
        Arrays.sort(g);
        System.out.println(g[0]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] weight = new int[N]; weight new int[N] N int sum =0; sum 0 int sum2 = 0; sum2 0 int[] g = new int[N]; g new int[N] N for(int j =0; j < N ; j++){
            weight[j] = sc.nextInt();

        } int j =0; int j =0; j 0 j < N j N j++ j++ j {
            weight[j] = sc.nextInt();

        } {
            weight[j] = sc.nextInt();

        } weight[j] = sc.nextInt() weight[j] weight j sc.nextInt() sc.nextInt sc for(int t =1; t <= N; t ++) {
            for (int i = 1; i <= N; i++) {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            }
            g[t-1] = Math.abs(sum - sum2);
            sum =0;
            sum2 =0;
        } int t =1; int t =1; t 1 t <= N t N t ++ t ++ t {
            for (int i = 1; i <= N; i++) {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            }
            g[t-1] = Math.abs(sum - sum2);
            sum =0;
            sum2 =0;
        } {
            for (int i = 1; i <= N; i++) {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            }
            g[t-1] = Math.abs(sum - sum2);
            sum =0;
            sum2 =0;
        } for (int i = 1; i <= N; i++) {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            } {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            } if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                } i <= t i t {
                    sum += weight[i-1];
                } sum += weight[i-1] sum weight[i-1] weight i-1 i 1 if(i > t){
                    sum2 += weight[i-1];
                } i > t i t {
                    sum2 += weight[i-1];
                } sum2 += weight[i-1] sum2 weight[i-1] weight i-1 i 1 g[t-1] = Math.abs(sum - sum2) g[t-1] g t-1 t 1 Math.abs(sum - sum2) Math.abs Math sum - sum2 sum sum2 sum =0 sum 0 sum2 =0 sum2 0 Arrays.sort(g) Arrays.sort Arrays g System.out.println(g[0]) System.out.println System.out System System.out g[0] g 0 String[] args args
import java.util.*;
import java.lang.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] weight = new int[N];
        int sum =0;
        int sum2 = 0;
        int[] g = new int[N];
        for(int j =0; j < N ; j++){
            weight[j] = sc.nextInt();

        }
        for(int t =1; t <= N; t ++) {
            for (int i = 1; i <= N; i++) {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            }
            g[t-1] = Math.abs(sum - sum2);
            sum =0;
            sum2 =0;
        }
        Arrays.sort(g);
        System.out.println(g[0]);
    }
}
