import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int w[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            }

            int b = sum;
            int b_pre = 0;
            for (int i = 0; i < n; i++) {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            }
            out.println(b);
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream 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) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int w[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            }

            int b = sum;
            int b_pre = 0;
            for (int i = 0; i < n; i++) {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            }
            out.println(b);
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) B solver = new B(); solver new B() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int w[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            }

            int b = sum;
            int b_pre = 0;
            for (int i = 0; i < n; i++) {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            }
            out.println(b);
        }

    } B public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int w[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            }

            int b = sum;
            int b_pre = 0;
            for (int i = 0; i < n; i++) {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            }
            out.println(b);
        } solve {
            // 入力
            int n = Integer.parseInt(in.next());
            int w[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            }

            int b = sum;
            int b_pre = 0;
            for (int i = 0; i < n; i++) {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            }
            out.println(b);
        } int n = Integer.parseInt(in.next()); n Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int w[] = new int[n]; w new int[n] n int sum = 0; sum 0 for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            } {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            } w[i] = Integer.parseInt(in.next()) w[i] w i Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in sum += w[i] sum w[i] w i int b = sum; b sum int b_pre = 0; b_pre 0 for (int i = 0; i < n; i++) {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            } {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            } b_pre += w[i] b_pre w[i] w i b = Math.min(b, Math.abs(b_pre - (sum - b_pre))) b Math.min(b, Math.abs(b_pre - (sum - b_pre))) Math.min Math b Math.abs(b_pre - (sum - b_pre)) Math.abs Math b_pre - (sum - b_pre) b_pre (sum - b_pre) sum b_pre out.println(b) out.println out b int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int w[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            }

            int b = sum;
            int b_pre = 0;
            for (int i = 0; i < n; i++) {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            }
            out.println(b);
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int w[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            }

            int b = sum;
            int b_pre = 0;
            for (int i = 0; i < n; i++) {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            }
            out.println(b);
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int w[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            }

            int b = sum;
            int b_pre = 0;
            for (int i = 0; i < n; i++) {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            }
            out.println(b);
        }

    }
}

