import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];

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

        int[] s = new int[n + 1];
        s[0] = 0;
        int sum = 0;
        for (int i = 1; i < s.length; i++) {
            s[i] = s[i - 1] + w[i - 1];
        }

        int result = 1000000;
        for (int t = 1; t < n; t++) {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        }

        System.out.println(result);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];

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

        int[] s = new int[n + 1];
        s[0] = 0;
        int sum = 0;
        for (int i = 1; i < s.length; i++) {
            s[i] = s[i - 1] + w[i - 1];
        }

        int result = 1000000;
        for (int t = 1; t < n; t++) {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        }

        System.out.println(result);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];

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

        int[] s = new int[n + 1];
        s[0] = 0;
        int sum = 0;
        for (int i = 1; i < s.length; i++) {
            s[i] = s[i - 1] + w[i - 1];
        }

        int result = 1000000;
        for (int t = 1; t < n; t++) {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        }

        System.out.println(result);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];

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

        int[] s = new int[n + 1];
        s[0] = 0;
        int sum = 0;
        for (int i = 1; i < s.length; i++) {
            s[i] = s[i - 1] + w[i - 1];
        }

        int result = 1000000;
        for (int t = 1; t < n; t++) {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        }

        System.out.println(result);
    } 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[] w = new int[n]; w new int[n] n for (int i = 0; i < n; i++) {
            w[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            w[i] = Integer.parseInt(sc.next());
        } {
            w[i] = Integer.parseInt(sc.next());
        } w[i] = Integer.parseInt(sc.next()) w[i] w i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] s = new int[n + 1]; s new int[n + 1] n + 1 n 1 s[0] = 0 s[0] s 0 0 int sum = 0; sum 0 for (int i = 1; i < s.length; i++) {
            s[i] = s[i - 1] + w[i - 1];
        } int i = 1; int i = 1; i 1 i < s.length i s.length s s.length i++ i++ i {
            s[i] = s[i - 1] + w[i - 1];
        } {
            s[i] = s[i - 1] + w[i - 1];
        } s[i] = s[i - 1] + w[i - 1] s[i] s i s[i - 1] + w[i - 1] s[i - 1] s i - 1 i 1 w[i - 1] w i - 1 i 1 int result = 1000000; result 1000000 for (int t = 1; t < n; t++) {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        } int t = 1; int t = 1; t 1 t < n t n t++ t++ t {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        } {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        } result = Math.min(result, Math.abs(s[t] - (s[n] - s[t]))) result Math.min(result, Math.abs(s[t] - (s[n] - s[t]))) Math.min Math result Math.abs(s[t] - (s[n] - s[t])) Math.abs Math s[t] - (s[n] - s[t]) s[t] s t (s[n] - s[t]) s[n] s n s[t] s t System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];

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

        int[] s = new int[n + 1];
        s[0] = 0;
        int sum = 0;
        for (int i = 1; i < s.length; i++) {
            s[i] = s[i - 1] + w[i - 1];
        }

        int result = 1000000;
        for (int t = 1; t < n; t++) {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        }

        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];

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

        int[] s = new int[n + 1];
        s[0] = 0;
        int sum = 0;
        for (int i = 1; i < s.length; i++) {
            s[i] = s[i - 1] + w[i - 1];
        }

        int result = 1000000;
        for (int t = 1; t < n; t++) {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        }

        System.out.println(result);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];

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

        int[] s = new int[n + 1];
        s[0] = 0;
        int sum = 0;
        for (int i = 1; i < s.length; i++) {
            s[i] = s[i - 1] + w[i - 1];
        }

        int result = 1000000;
        for (int t = 1; t < n; t++) {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        }

        System.out.println(result);
    }
}
