import 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 a = 0, b = 0, ans = 20000;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            a += w[i];
        }
        for (int i = 0; i < n; i++) {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java 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 a = 0, b = 0, ans = 20000;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            a += w[i];
        }
        for (int i = 0; i < n; i++) {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int a = 0, b = 0, ans = 20000;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            a += w[i];
        }
        for (int i = 0; i < n; i++) {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int a = 0, b = 0, ans = 20000;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            a += w[i];
        }
        for (int i = 0; i < n; i++) {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        }
        System.out.println(ans);
    } 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 a = 0 a 0 b = 0 b 0 ans = 20000; ans 20000 for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            a += w[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            w[i] = sc.nextInt();
            a += w[i];
        } {
            w[i] = sc.nextInt();
            a += w[i];
        } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc a += w[i] a w[i] w i for (int i = 0; i < n; i++) {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        } {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        } a -= w[i] a w[i] w i b += w[i] b w[i] w i ans = Math.min(ans, Math.abs(a-b)) ans Math.min(ans, Math.abs(a-b)) Math.min Math ans Math.abs(a-b) Math.abs Math a-b a b 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 = sc.nextInt();
        int[] w = new int[n];
        int a = 0, b = 0, ans = 20000;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            a += w[i];
        }
        for (int i = 0; i < n; i++) {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        }
        System.out.println(ans);
    }
} 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 a = 0, b = 0, ans = 20000;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            a += w[i];
        }
        for (int i = 0; i < n; i++) {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        }
        System.out.println(ans);
    }
} Main
import 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 a = 0, b = 0, ans = 20000;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            a += w[i];
        }
        for (int i = 0; i < n; i++) {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        }
        System.out.println(ans);
    }
}