import java.util.Scanner;

public class Main {
    //Balance
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), sum = 0;
        int[] W = new int[n];
        for (int i = 0; i < n; i++) {
            W[i] = sc.nextInt();
            sum += W[i];
        }
        int sum1 = 0, sum2 = sum, minDiff = Integer.MAX_VALUE;
        for (int w : W) {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        }
        sc.close();
        System.out.println(minDiff);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    //Balance
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), sum = 0;
        int[] W = new int[n];
        for (int i = 0; i < n; i++) {
            W[i] = sc.nextInt();
            sum += W[i];
        }
        int sum1 = 0, sum2 = sum, minDiff = Integer.MAX_VALUE;
        for (int w : W) {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        }
        sc.close();
        System.out.println(minDiff);
    }
} Main //Balance
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), sum = 0;
        int[] W = new int[n];
        for (int i = 0; i < n; i++) {
            W[i] = sc.nextInt();
            sum += W[i];
        }
        int sum1 = 0, sum2 = sum, minDiff = Integer.MAX_VALUE;
        for (int w : W) {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        }
        sc.close();
        System.out.println(minDiff);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), sum = 0;
        int[] W = new int[n];
        for (int i = 0; i < n; i++) {
            W[i] = sc.nextInt();
            sum += W[i];
        }
        int sum1 = 0, sum2 = sum, minDiff = Integer.MAX_VALUE;
        for (int w : W) {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        }
        sc.close();
        System.out.println(minDiff);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt() n sc.nextInt() sc.nextInt sc sum = 0; sum 0 int[] W = new int[n]; W new int[n] n for (int i = 0; i < n; i++) {
            W[i] = sc.nextInt();
            sum += W[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            W[i] = sc.nextInt();
            sum += W[i];
        } {
            W[i] = sc.nextInt();
            sum += W[i];
        } W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc sum += W[i] sum W[i] W i int sum1 = 0 sum1 0 sum2 = sum sum2 sum minDiff = Integer.MAX_VALUE; minDiff Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int w : W) {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        } int w W {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        } {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        } sum1 += w sum1 w sum2 -= w sum2 w minDiff = Math.min(minDiff, Math.abs(sum1 - sum2)) minDiff Math.min(minDiff, Math.abs(sum1 - sum2)) Math.min Math minDiff Math.abs(sum1 - sum2) Math.abs Math sum1 - sum2 sum1 sum2 sc.close() sc.close sc System.out.println(minDiff) System.out.println System.out System System.out minDiff String[] args args public class Main {
    //Balance
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), sum = 0;
        int[] W = new int[n];
        for (int i = 0; i < n; i++) {
            W[i] = sc.nextInt();
            sum += W[i];
        }
        int sum1 = 0, sum2 = sum, minDiff = Integer.MAX_VALUE;
        for (int w : W) {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        }
        sc.close();
        System.out.println(minDiff);
    }
} public class Main {
    //Balance
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), sum = 0;
        int[] W = new int[n];
        for (int i = 0; i < n; i++) {
            W[i] = sc.nextInt();
            sum += W[i];
        }
        int sum1 = 0, sum2 = sum, minDiff = Integer.MAX_VALUE;
        for (int w : W) {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        }
        sc.close();
        System.out.println(minDiff);
    }
} Main
import java.util.Scanner;

public class Main {
    //Balance
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), sum = 0;
        int[] W = new int[n];
        for (int i = 0; i < n; i++) {
            W[i] = sc.nextInt();
            sum += W[i];
        }
        int sum1 = 0, sum2 = sum, minDiff = Integer.MAX_VALUE;
        for (int w : W) {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        }
        sc.close();
        System.out.println(minDiff);
    }
}
