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

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += w[i];
        }

        int ans = sum;
        for (int i = 1; i <= n; i++) {
            int under = 0;
            for (int j = 0; j < i; j++) {
                under += w[j];
            }
            // System.out.printf("%s -> %s : %s = %s\n", i, under, sum - under,
            // Math.abs(sum - under - under));
            ans = Math.min(Math.abs(sum - under - under), 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 = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += w[i];
        }

        int ans = sum;
        for (int i = 1; i <= n; i++) {
            int under = 0;
            for (int j = 0; j < i; j++) {
                under += w[j];
            }
            // System.out.printf("%s -> %s : %s = %s\n", i, under, sum - under,
            // Math.abs(sum - under - under));
            ans = Math.min(Math.abs(sum - under - under), ans);
        }

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

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += w[i];
        }

        int ans = sum;
        for (int i = 1; i <= n; i++) {
            int under = 0;
            for (int j = 0; j < i; j++) {
                under += w[j];
            }
            // System.out.printf("%s -> %s : %s = %s\n", i, under, sum - under,
            // Math.abs(sum - under - under));
            ans = Math.min(Math.abs(sum - under - under), ans);
        }

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

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += w[i];
        }

        int ans = sum;
        for (int i = 1; i <= n; i++) {
            int under = 0;
            for (int j = 0; j < i; j++) {
                under += w[j];
            }
            // System.out.printf("%s -> %s : %s = %s\n", i, under, sum - under,
            // Math.abs(sum - under - under));
            ans = Math.min(Math.abs(sum - under - under), ans);
        }

        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 for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            w[i] = sc.nextInt();
        } {
            w[i] = sc.nextInt();
        } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc int sum = 0; sum 0 for (int i = 0; i < n; i++) {
            sum += w[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            sum += w[i];
        } {
            sum += w[i];
        } sum += w[i] sum w[i] w i int ans = sum; ans sum for (int i = 1; i <= n; i++) {
            int under = 0;
            for (int j = 0; j < i; j++) {
                under += w[j];
            }
            // System.out.printf("%s -> %s : %s = %s\n", i, under, sum - under,
            // Math.abs(sum - under - under));
            ans = Math.min(Math.abs(sum - under - under), ans);
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            int under = 0;
            for (int j = 0; j < i; j++) {
                under += w[j];
            }
            // System.out.printf("%s -> %s : %s = %s\n", i, under, sum - under,
            // Math.abs(sum - under - under));
            ans = Math.min(Math.abs(sum - under - under), ans);
        } {
            int under = 0;
            for (int j = 0; j < i; j++) {
                under += w[j];
            }
            // System.out.printf("%s -> %s : %s = %s\n", i, under, sum - under,
            // Math.abs(sum - under - under));
            ans = Math.min(Math.abs(sum - under - under), ans);
        } int under = 0; under 0 for (int j = 0; j < i; j++) {
                under += w[j];
            } int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
                under += w[j];
            } {
                under += w[j];
            } under += w[j] under w[j] w j ans = Math.min(Math.abs(sum - under - under), ans) ans Math.min(Math.abs(sum - under - under), ans) Math.min Math Math.abs(sum - under - under) Math.abs Math sum - under - under sum - under - under sum under under 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 = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += w[i];
        }

        int ans = sum;
        for (int i = 1; i <= n; i++) {
            int under = 0;
            for (int j = 0; j < i; j++) {
                under += w[j];
            }
            // System.out.printf("%s -> %s : %s = %s\n", i, under, sum - under,
            // Math.abs(sum - under - under));
            ans = Math.min(Math.abs(sum - under - under), ans);
        }

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

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += w[i];
        }

        int ans = sum;
        for (int i = 1; i <= n; i++) {
            int under = 0;
            for (int j = 0; j < i; j++) {
                under += w[j];
            }
            // System.out.printf("%s -> %s : %s = %s\n", i, under, sum - under,
            // Math.abs(sum - under - under));
            ans = Math.min(Math.abs(sum - under - under), 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 = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += w[i];
        }

        int ans = sum;
        for (int i = 1; i <= n; i++) {
            int under = 0;
            for (int j = 0; j < i; j++) {
                under += w[j];
            }
            // System.out.printf("%s -> %s : %s = %s\n", i, under, sum - under,
            // Math.abs(sum - under - under));
            ans = Math.min(Math.abs(sum - under - under), ans);
        }

        System.out.println(ans);
    }

}
