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];
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
            }

            int b = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            }
            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];
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
            }

            int b = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            }
            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];
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
            }

            int b = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            }
            out.println(b);
        }

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

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

            int b = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            }
            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 for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                w[i] = Integer.parseInt(in.next());
            } {
                w[i] = Integer.parseInt(in.next());
            } w[i] = Integer.parseInt(in.next()) w[i] w i Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int b = Integer.MAX_VALUE; b Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 1; i < n; i++) {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            } {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            } int s1 = 0; s1 0 int s2 = 0; s2 0 for (int j = 0; j < i; j++) {
                    s1 += w[j];
                } int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
                    s1 += w[j];
                } {
                    s1 += w[j];
                } s1 += w[j] s1 w[j] w j for (int j = i; j < n; j++) {
                    s2 += w[j];
                } int j = i; int j = i; j i j < n j n j++ j++ j {
                    s2 += w[j];
                } {
                    s2 += w[j];
                } s2 += w[j] s2 w[j] w j b = Math.min(b, Math.abs(s2 - s1)) b Math.min(b, Math.abs(s2 - s1)) Math.min Math b Math.abs(s2 - s1) Math.abs Math s2 - s1 s2 s1 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];
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
            }

            int b = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            }
            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];
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
            }

            int b = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            }
            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];
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
            }

            int b = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            }
            out.println(b);
        }

    }
}

