import java.util.Scanner;

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 total = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            total += w[i];
        }

        int s1 = 0;
        int s2;
        int ans = total;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 = total - s1;
            int candidate = Math.abs(s1 - s2);
            if (candidate < ans) {
                ans = candidate;
            }
        }
        System.out.println(ans);

        sc.close();

    }

} import java.util.Scanner; Scanner 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 total = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            total += w[i];
        }

        int s1 = 0;
        int s2;
        int ans = total;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 = total - s1;
            int candidate = Math.abs(s1 - s2);
            if (candidate < ans) {
                ans = candidate;
            }
        }
        System.out.println(ans);

        sc.close();

    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            total += w[i];
        }

        int s1 = 0;
        int s2;
        int ans = total;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 = total - s1;
            int candidate = Math.abs(s1 - s2);
            if (candidate < ans) {
                ans = candidate;
            }
        }
        System.out.println(ans);

        sc.close();

    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            total += w[i];
        }

        int s1 = 0;
        int s2;
        int ans = total;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 = total - s1;
            int candidate = Math.abs(s1 - s2);
            if (candidate < ans) {
                ans = candidate;
            }
        }
        System.out.println(ans);

        sc.close();

    } 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 total = 0; total 0 for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            total += w[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            w[i] = sc.nextInt();
            total += w[i];
        } {
            w[i] = sc.nextInt();
            total += w[i];
        } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc total += w[i] total w[i] w i int s1 = 0; s1 0 int s2; s2 int ans = total; ans total for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 = total - s1;
            int candidate = Math.abs(s1 - s2);
            if (candidate < ans) {
                ans = candidate;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            s1 += w[i];
            s2 = total - s1;
            int candidate = Math.abs(s1 - s2);
            if (candidate < ans) {
                ans = candidate;
            }
        } {
            s1 += w[i];
            s2 = total - s1;
            int candidate = Math.abs(s1 - s2);
            if (candidate < ans) {
                ans = candidate;
            }
        } s1 += w[i] s1 w[i] w i s2 = total - s1 s2 total - s1 total s1 int candidate = Math.abs(s1 - s2); candidate Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 if (candidate < ans) {
                ans = candidate;
            } candidate < ans candidate ans {
                ans = candidate;
            } ans = candidate ans candidate System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc 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 total = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            total += w[i];
        }

        int s1 = 0;
        int s2;
        int ans = total;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 = total - s1;
            int candidate = Math.abs(s1 - s2);
            if (candidate < ans) {
                ans = candidate;
            }
        }
        System.out.println(ans);

        sc.close();

    }

} 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 total = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            total += w[i];
        }

        int s1 = 0;
        int s2;
        int ans = total;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 = total - s1;
            int candidate = Math.abs(s1 - s2);
            if (candidate < ans) {
                ans = candidate;
            }
        }
        System.out.println(ans);

        sc.close();

    }

} Main
import java.util.Scanner;

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 total = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            total += w[i];
        }

        int s1 = 0;
        int s2;
        int ans = total;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 = total - s1;
            int candidate = Math.abs(s1 - s2);
            if (candidate < ans) {
                ans = candidate;
            }
        }
        System.out.println(ans);

        sc.close();

    }

}
