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);
        }
    }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz