import java.util.*;

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

        int s1 = 0;
        int s2 = sum;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));

        }
        System.out.println(min);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            w[i] = scanner.nextInt();
            sum += w[i];
        }

        int s1 = 0;
        int s2 = sum;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));

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

        int s1 = 0;
        int s2 = sum;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));

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

        int s1 = 0;
        int s2 = sum;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));

        }
        System.out.println(min);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int[] w = new int[n]; w new int[n] n int sum = 0; sum 0 for (int i = 0; i < n; i++) {
            w[i] = scanner.nextInt();
            sum += w[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            w[i] = scanner.nextInt();
            sum += w[i];
        } {
            w[i] = scanner.nextInt();
            sum += w[i];
        } w[i] = scanner.nextInt() w[i] w i scanner.nextInt() scanner.nextInt scanner sum += w[i] sum w[i] w i int s1 = 0; s1 0 int s2 = sum; s2 sum int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));

        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));

        } {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));

        } s1 += w[i] s1 w[i] w i s2 -= w[i] s2 w[i] w i min = Math.min(min, Math.abs(s1 - s2)) min Math.min(min, Math.abs(s1 - s2)) Math.min Math min Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 System.out.println(min) System.out.println System.out System System.out min String args[] args public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            w[i] = scanner.nextInt();
            sum += w[i];
        }

        int s1 = 0;
        int s2 = sum;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));

        }
        System.out.println(min);
    }
} public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            w[i] = scanner.nextInt();
            sum += w[i];
        }

        int s1 = 0;
        int s2 = sum;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));

        }
        System.out.println(min);
    }
} Main
import java.util.*;

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

        int s1 = 0;
        int s2 = sum;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));

        }
        System.out.println(min);
    }
}