import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:36-

            int n = sc.nextInt();
            int[] ws = new int[n];
            for (int i = 0; i < ws.length; i++) ws[i] = sc.nextInt();

            int[] p1 = new int[n];
            int[] p2 = new int[n];
            for (int i = 0; i < ws.length; i++) {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            }

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

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < ws.length - 1; i++) {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            }

            out.println(min);
        }
    }
} import java.io.BufferedInputStream; BufferedInputStream java.io import java.io.BufferedOutputStream; BufferedOutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:36-

            int n = sc.nextInt();
            int[] ws = new int[n];
            for (int i = 0; i < ws.length; i++) ws[i] = sc.nextInt();

            int[] p1 = new int[n];
            int[] p2 = new int[n];
            for (int i = 0; i < ws.length; i++) {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            }

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

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < ws.length - 1; i++) {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            }

            out.println(min);
        }
    }
} Main public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:36-

            int n = sc.nextInt();
            int[] ws = new int[n];
            for (int i = 0; i < ws.length; i++) ws[i] = sc.nextInt();

            int[] p1 = new int[n];
            int[] p2 = new int[n];
            for (int i = 0; i < ws.length; i++) {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            }

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

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < ws.length - 1; i++) {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            }

            out.println(min);
        }
    } main {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:36-

            int n = sc.nextInt();
            int[] ws = new int[n];
            for (int i = 0; i < ws.length; i++) ws[i] = sc.nextInt();

            int[] p1 = new int[n];
            int[] p2 = new int[n];
            for (int i = 0; i < ws.length; i++) {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            }

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

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < ws.length - 1; i++) {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            }

            out.println(min);
        }
    } try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:36-

            int n = sc.nextInt();
            int[] ws = new int[n];
            for (int i = 0; i < ws.length; i++) ws[i] = sc.nextInt();

            int[] p1 = new int[n];
            int[] p2 = new int[n];
            for (int i = 0; i < ws.length; i++) {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            }

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

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < ws.length - 1; i++) {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            }

            out.println(min);
        } {

            Scanner sc = new Scanner(in);

            // 10:36-

            int n = sc.nextInt();
            int[] ws = new int[n];
            for (int i = 0; i < ws.length; i++) ws[i] = sc.nextInt();

            int[] p1 = new int[n];
            int[] p2 = new int[n];
            for (int i = 0; i < ws.length; i++) {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            }

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

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < ws.length - 1; i++) {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            }

            out.println(min);
        } BufferedInputStream in = new BufferedInputStream(System.in) BufferedInputStream in = new BufferedInputStream(System.in) new BufferedInputStream(System.in) PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)) PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)) new PrintWriter(new BufferedOutputStream(System.out)) Scanner sc = new Scanner(in); sc new Scanner(in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] ws = new int[n]; ws new int[n] n for (int i = 0; i < ws.length; i++) ws[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < ws.length i ws.length ws ws.length i++ i++ i ws[i] = sc.nextInt(); ws[i] = sc.nextInt() ws[i] ws i sc.nextInt() sc.nextInt sc int[] p1 = new int[n]; p1 new int[n] n int[] p2 = new int[n]; p2 new int[n] n for (int i = 0; i < ws.length; i++) {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            } int i = 0; int i = 0; i 0 i < ws.length i ws.length ws ws.length i++ i++ i {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            } {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            } p1[i] += ws[i] p1[i] p1 i ws[i] ws i if (i > 0) p1[i] += p1[i - 1]; i > 0 i 0 p1[i] += p1[i - 1] p1[i] p1 i p1[i - 1] p1 i - 1 i 1 for (int i = ws.length - 1; i >= 0; i--) {
                p2[i] += ws[i];
                if (i < ws.length - 1) p2[i] += p2[i + 1];
            } int i = ws.length - 1; int i = ws.length - 1; i ws.length - 1 ws.length ws ws.length 1 i >= 0 i 0 i-- i-- i {
                p2[i] += ws[i];
                if (i < ws.length - 1) p2[i] += p2[i + 1];
            } {
                p2[i] += ws[i];
                if (i < ws.length - 1) p2[i] += p2[i + 1];
            } p2[i] += ws[i] p2[i] p2 i ws[i] ws i if (i < ws.length - 1) p2[i] += p2[i + 1]; i < ws.length - 1 i ws.length - 1 ws.length ws ws.length 1 p2[i] += p2[i + 1] p2[i] p2 i p2[i + 1] p2 i + 1 i 1 int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < ws.length - 1; i++) {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            } int i = 0; int i = 0; i 0 i < ws.length - 1 i ws.length - 1 ws.length ws ws.length 1 i++ i++ i {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            } {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            } min = Math.min(min, Math.abs(p1[i] - p2[i + 1])) min Math.min(min, Math.abs(p1[i] - p2[i + 1])) Math.min Math min Math.abs(p1[i] - p2[i + 1]) Math.abs Math p1[i] - p2[i + 1] p1[i] p1 i p2[i + 1] p2 i + 1 i 1 out.println(min) out.println out min String[] args args public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:36-

            int n = sc.nextInt();
            int[] ws = new int[n];
            for (int i = 0; i < ws.length; i++) ws[i] = sc.nextInt();

            int[] p1 = new int[n];
            int[] p2 = new int[n];
            for (int i = 0; i < ws.length; i++) {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            }

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

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < ws.length - 1; i++) {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            }

            out.println(min);
        }
    }
} public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:36-

            int n = sc.nextInt();
            int[] ws = new int[n];
            for (int i = 0; i < ws.length; i++) ws[i] = sc.nextInt();

            int[] p1 = new int[n];
            int[] p2 = new int[n];
            for (int i = 0; i < ws.length; i++) {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            }

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

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < ws.length - 1; i++) {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            }

            out.println(min);
        }
    }
} Main
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:36-

            int n = sc.nextInt();
            int[] ws = new int[n];
            for (int i = 0; i < ws.length; i++) ws[i] = sc.nextInt();

            int[] p1 = new int[n];
            int[] p2 = new int[n];
            for (int i = 0; i < ws.length; i++) {
                p1[i] += ws[i];
                if (i > 0) p1[i] += p1[i - 1];
            }

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

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < ws.length - 1; i++) {
                min = Math.min(min, Math.abs(p1[i] - p2[i + 1]));
            }

            out.println(min);
        }
    }
}
