import java.util.Arrays;
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 < W.length; ++i) {
            W[i] = sc.nextInt();
        }

        System.out.println(solve(W));

        sc.close();
    }

    static int solve(int[] W) {
        int total = Arrays.stream(W).sum();
        int result = Integer.MAX_VALUE;
        int leftSum = 0;
        for (int i = 0; i < W.length - 1; ++i) {
            leftSum += W[i];

            result = Math.min(result, Math.abs(total - leftSum - leftSum));
        }

        return result;
    }
} import java.util.Arrays; Arrays java.util 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 < W.length; ++i) {
            W[i] = sc.nextInt();
        }

        System.out.println(solve(W));

        sc.close();
    }

    static int solve(int[] W) {
        int total = Arrays.stream(W).sum();
        int result = Integer.MAX_VALUE;
        int leftSum = 0;
        for (int i = 0; i < W.length - 1; ++i) {
            leftSum += W[i];

            result = Math.min(result, Math.abs(total - leftSum - leftSum));
        }

        return result;
    }
} 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 < W.length; ++i) {
            W[i] = sc.nextInt();
        }

        System.out.println(solve(W));

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < W.length; ++i) {
            W[i] = sc.nextInt();
        }

        System.out.println(solve(W));

        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 for (int i = 0; i < W.length; ++i) {
            W[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < W.length i W.length W W.length ++i ++i i {
            W[i] = sc.nextInt();
        } {
            W[i] = sc.nextInt();
        } W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc System.out.println(solve(W)) System.out.println System.out System System.out solve(W) solve W sc.close() sc.close sc String[] args args static int solve(int[] W) {
        int total = Arrays.stream(W).sum();
        int result = Integer.MAX_VALUE;
        int leftSum = 0;
        for (int i = 0; i < W.length - 1; ++i) {
            leftSum += W[i];

            result = Math.min(result, Math.abs(total - leftSum - leftSum));
        }

        return result;
    } solve {
        int total = Arrays.stream(W).sum();
        int result = Integer.MAX_VALUE;
        int leftSum = 0;
        for (int i = 0; i < W.length - 1; ++i) {
            leftSum += W[i];

            result = Math.min(result, Math.abs(total - leftSum - leftSum));
        }

        return result;
    } int total = Arrays.stream(W).sum(); total Arrays.stream(W).sum() Arrays.stream(W).sum Arrays.stream(W) Arrays.stream Arrays W int result = Integer.MAX_VALUE; result Integer.MAX_VALUE Integer Integer.MAX_VALUE int leftSum = 0; leftSum 0 for (int i = 0; i < W.length - 1; ++i) {
            leftSum += W[i];

            result = Math.min(result, Math.abs(total - leftSum - leftSum));
        } int i = 0; int i = 0; i 0 i < W.length - 1 i W.length - 1 W.length W W.length 1 ++i ++i i {
            leftSum += W[i];

            result = Math.min(result, Math.abs(total - leftSum - leftSum));
        } {
            leftSum += W[i];

            result = Math.min(result, Math.abs(total - leftSum - leftSum));
        } leftSum += W[i] leftSum W[i] W i result = Math.min(result, Math.abs(total - leftSum - leftSum)) result Math.min(result, Math.abs(total - leftSum - leftSum)) Math.min Math result Math.abs(total - leftSum - leftSum) Math.abs Math total - leftSum - leftSum total - leftSum - leftSum total leftSum leftSum return result; result int[] W W 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 < W.length; ++i) {
            W[i] = sc.nextInt();
        }

        System.out.println(solve(W));

        sc.close();
    }

    static int solve(int[] W) {
        int total = Arrays.stream(W).sum();
        int result = Integer.MAX_VALUE;
        int leftSum = 0;
        for (int i = 0; i < W.length - 1; ++i) {
            leftSum += W[i];

            result = Math.min(result, Math.abs(total - leftSum - leftSum));
        }

        return result;
    }
} 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 < W.length; ++i) {
            W[i] = sc.nextInt();
        }

        System.out.println(solve(W));

        sc.close();
    }

    static int solve(int[] W) {
        int total = Arrays.stream(W).sum();
        int result = Integer.MAX_VALUE;
        int leftSum = 0;
        for (int i = 0; i < W.length - 1; ++i) {
            leftSum += W[i];

            result = Math.min(result, Math.abs(total - leftSum - leftSum));
        }

        return result;
    }
} Main
import java.util.Arrays;
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 < W.length; ++i) {
            W[i] = sc.nextInt();
        }

        System.out.println(solve(W));

        sc.close();
    }

    static int solve(int[] W) {
        int total = Arrays.stream(W).sum();
        int result = Integer.MAX_VALUE;
        int leftSum = 0;
        for (int i = 0; i < W.length - 1; ++i) {
            leftSum += W[i];

            result = Math.min(result, Math.abs(total - leftSum - leftSum));
        }

        return result;
    }
}