import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int N = nextInt();

        int[] weights = new int[N];

        for (int i = 0; i < weights.length; i++) {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        }

        int min = Integer.MAX_VALUE;

        for (int i = 0; i < weights.length - 1; i++) min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i]));

        System.out.println(min);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
} import java.io.*; io.* java import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int N = nextInt();

        int[] weights = new int[N];

        for (int i = 0; i < weights.length; i++) {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        }

        int min = Integer.MAX_VALUE;

        for (int i = 0; i < weights.length - 1; i++) min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i]));

        System.out.println(min);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
} Main //Input Reader
    private static BufferedReader reader; reader private static StringTokenizer tokenizer; tokenizer public static void main(String[] args) throws IOException {
        init();

        int N = nextInt();

        int[] weights = new int[N];

        for (int i = 0; i < weights.length; i++) {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        }

        int min = Integer.MAX_VALUE;

        for (int i = 0; i < weights.length - 1; i++) min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i]));

        System.out.println(min);
    } main {
        init();

        int N = nextInt();

        int[] weights = new int[N];

        for (int i = 0; i < weights.length; i++) {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        }

        int min = Integer.MAX_VALUE;

        for (int i = 0; i < weights.length - 1; i++) min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i]));

        System.out.println(min);
    } init() init int N = nextInt(); N nextInt() nextInt int[] weights = new int[N]; weights new int[N] N for (int i = 0; i < weights.length; i++) {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        } int i = 0; int i = 0; i 0 i < weights.length i weights.length weights weights.length i++ i++ i {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        } {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        } weights[i] = nextInt() weights[i] weights i nextInt() nextInt if (i > 0) weights[i] += weights[i - 1]; i > 0 i 0 weights[i] += weights[i - 1] weights[i] weights i weights[i - 1] weights i - 1 i 1 int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < weights.length - 1; i++) min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i])); int i = 0; int i = 0; i 0 i < weights.length - 1 i weights.length - 1 weights.length weights weights.length 1 i++ i++ i min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i])); min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i])) min Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i])) Math.min Math min Math.abs(weights[weights.length - 1] - 2*weights[i]) Math.abs Math weights[weights.length - 1] - 2*weights[i] weights[weights.length - 1] weights weights.length - 1 weights.length weights weights.length 1 2*weights[i] 2 weights[i] weights i System.out.println(min) System.out.println System.out System System.out min String[] args args private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    } init {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    } reader = new BufferedReader(new InputStreamReader(System.in)) reader new BufferedReader(new InputStreamReader(System.in)) tokenizer = new StringTokenizer("") tokenizer new StringTokenizer("") private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    } next {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    } String read; read while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        } !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        } read = reader.readLine() read reader.readLine() reader.readLine reader if (read == null || read.equals(""))
                return "-1"; read == null || read.equals("") read == null read null read.equals("") read.equals read "" return "-1"; "-1" tokenizer = new StringTokenizer(read) tokenizer new StringTokenizer(read) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    } nextInt {
        return Integer.parseInt(next());
    } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int N = nextInt();

        int[] weights = new int[N];

        for (int i = 0; i < weights.length; i++) {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        }

        int min = Integer.MAX_VALUE;

        for (int i = 0; i < weights.length - 1; i++) min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i]));

        System.out.println(min);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
} public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int N = nextInt();

        int[] weights = new int[N];

        for (int i = 0; i < weights.length; i++) {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        }

        int min = Integer.MAX_VALUE;

        for (int i = 0; i < weights.length - 1; i++) min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i]));

        System.out.println(min);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
} Main
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int N = nextInt();

        int[] weights = new int[N];

        for (int i = 0; i < weights.length; i++) {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        }

        int min = Integer.MAX_VALUE;

        for (int i = 0; i < weights.length - 1; i++) min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i]));

        System.out.println(min);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}