
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型
        int[] w = new int[n+1];

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

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

        System.out.println(ans);
    }
} 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型
        int[] w = new int[n+1];

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

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

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

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

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

        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());//int型
        int[] w = new int[n+1];

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

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

        System.out.println(ans);
    } 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+1]; w new int[n+1] n+1 n 1 w[0] = 0 w[0] w 0 0 for (int i = 0; i < n; i++) {
            w[i+1] = w[i]+Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            w[i+1] = w[i]+Integer.parseInt(sc.next());
        } {
            w[i+1] = w[i]+Integer.parseInt(sc.next());
        } w[i+1] = w[i]+Integer.parseInt(sc.next()) w[i+1] w i+1 i 1 w[i]+Integer.parseInt(sc.next()) w[i] w i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc int ans = 10000000; ans 10000000 int r; r int l; l for (int i = 1; i < n; i++) {
            r = w[i];
            l = w[n] - w[i];
            ans = Math.min(Math.abs(l-r),ans);
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            r = w[i];
            l = w[n] - w[i];
            ans = Math.min(Math.abs(l-r),ans);
        } {
            r = w[i];
            l = w[n] - w[i];
            ans = Math.min(Math.abs(l-r),ans);
        } r = w[i] r w[i] w i l = w[n] - w[i] l w[n] - w[i] w[n] w n w[i] w i ans = Math.min(Math.abs(l-r),ans) ans Math.min(Math.abs(l-r),ans) Math.min Math Math.abs(l-r) Math.abs Math l-r l r ans System.out.println(ans) System.out.println System.out System System.out ans 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型
        int[] w = new int[n+1];

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

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

        System.out.println(ans);
    }
} public class Main {

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

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

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

        System.out.println(ans);
    }
} 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型
        int[] w = new int[n+1];

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

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

        System.out.println(ans);
    }
}
