import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] weight = new int[n];
        for (int i = 0; i < n; i++) {
            weight[i] = Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            int left_sum = 0;
            int right_sum = 0;
            for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            }
            for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            }
            if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            }
        }
        System.out.println(min);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] weight = new int[n];
        for (int i = 0; i < n; i++) {
            weight[i] = Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            int left_sum = 0;
            int right_sum = 0;
            for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            }
            for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            }
            if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            }
        }
        System.out.println(min);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] weight = new int[n];
        for (int i = 0; i < n; i++) {
            weight[i] = Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            int left_sum = 0;
            int right_sum = 0;
            for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            }
            for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            }
            if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            }
        }
        System.out.println(min);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] weight = new int[n];
        for (int i = 0; i < n; i++) {
            weight[i] = Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            int left_sum = 0;
            int right_sum = 0;
            for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            }
            for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            }
            if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            }
        }
        System.out.println(min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] weight = new int[n]; weight new int[n] n for (int i = 0; i < n; i++) {
            weight[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            weight[i] = Integer.parseInt(sc.next());
        } {
            weight[i] = Integer.parseInt(sc.next());
        } weight[i] = Integer.parseInt(sc.next()) weight[i] weight i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < n - 1; i++) {
            int left_sum = 0;
            int right_sum = 0;
            for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            }
            for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            }
            if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            }
        } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
            int left_sum = 0;
            int right_sum = 0;
            for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            }
            for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            }
            if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            }
        } {
            int left_sum = 0;
            int right_sum = 0;
            for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            }
            for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            }
            if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            }
        } int left_sum = 0; left_sum 0 int right_sum = 0; right_sum 0 for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            } int j = 0; int j = 0; j 0 j <= i j i j++ j++ j {
                left_sum += weight[j];
            } {
                left_sum += weight[j];
            } left_sum += weight[j] left_sum weight[j] weight j for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            } int j = i + 1; int j = i + 1; j i + 1 i 1 j < n j n j++ j++ j {
                right_sum += weight[j];
            } {
                right_sum += weight[j];
            } right_sum += weight[j] right_sum weight[j] weight j if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            } min > Math.abs(left_sum - right_sum) min Math.abs(left_sum - right_sum) Math.abs Math left_sum - right_sum left_sum right_sum {
                min = Math.abs(left_sum - right_sum);
            } min = Math.abs(left_sum - right_sum) min Math.abs(left_sum - right_sum) Math.abs Math left_sum - right_sum left_sum right_sum System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] weight = new int[n];
        for (int i = 0; i < n; i++) {
            weight[i] = Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            int left_sum = 0;
            int right_sum = 0;
            for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            }
            for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            }
            if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            }
        }
        System.out.println(min);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] weight = new int[n];
        for (int i = 0; i < n; i++) {
            weight[i] = Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            int left_sum = 0;
            int right_sum = 0;
            for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            }
            for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            }
            if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            }
        }
        System.out.println(min);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] weight = new int[n];
        for (int i = 0; i < n; i++) {
            weight[i] = Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            int left_sum = 0;
            int right_sum = 0;
            for (int j = 0; j <= i; j++) {
                left_sum += weight[j];
            }
            for (int j = i + 1; j < n; j++) {
                right_sum += weight[j];
            }
            if (min > Math.abs(left_sum - right_sum)) {
                min = Math.abs(left_sum - right_sum);
            }
        }
        System.out.println(min);
    }
}