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);
        ABC129_b solver = new ABC129_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC129_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int arr[] = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            }
            int diff = 999;
            for (int T = 0; T < N; T++) {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            }
            out.println(diff);

        }

    }
}
 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);
        ABC129_b solver = new ABC129_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC129_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int arr[] = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            }
            int diff = 999;
            for (int T = 0; T < N; T++) {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            }
            out.println(diff);

        }

    }
} 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);
        ABC129_b solver = new ABC129_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);
        ABC129_b solver = new ABC129_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) ABC129_b solver = new ABC129_b(); solver new ABC129_b() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class ABC129_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int arr[] = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            }
            int diff = 999;
            for (int T = 0; T < N; T++) {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            }
            out.println(diff);

        }

    } ABC129_b public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int arr[] = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            }
            int diff = 999;
            for (int T = 0; T < N; T++) {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            }
            out.println(diff);

        } solve {
            int N = in.nextInt();
            int arr[] = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            }
            int diff = 999;
            for (int T = 0; T < N; T++) {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            }
            out.println(diff);

        } int N = in.nextInt(); N in.nextInt() in.nextInt in int arr[] = new int[N]; arr new int[N] N for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                arr[i] = in.nextInt();
            } {
                arr[i] = in.nextInt();
            } arr[i] = in.nextInt() arr[i] arr i in.nextInt() in.nextInt in int diff = 999; diff 999 for (int T = 0; T < N; T++) {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            } int T = 0; int T = 0; T 0 T < N T N T++ T++ T {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            } {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            } int left = 0; left 0 int right = 0; right 0 for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                } {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                } if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    } i <= T i T {
                        left += arr[i];
                    } left += arr[i] left arr[i] arr i {
                        right += arr[i];
                    } right += arr[i] right arr[i] arr i if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                } diff > (Math.abs(left - right)) diff (Math.abs(left - right)) Math.abs Math left - right left right {
                    diff = (Math.abs(left - right));
                } diff = (Math.abs(left - right)) diff (Math.abs(left - right)) Math.abs Math left - right left right out.println(diff) out.println out diff 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);
        ABC129_b solver = new ABC129_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC129_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int arr[] = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            }
            int diff = 999;
            for (int T = 0; T < N; T++) {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            }
            out.println(diff);

        }

    }
} 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);
        ABC129_b solver = new ABC129_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC129_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int arr[] = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            }
            int diff = 999;
            for (int T = 0; T < N; T++) {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            }
            out.println(diff);

        }

    }
} 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);
        ABC129_b solver = new ABC129_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC129_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int arr[] = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            }
            int diff = 999;
            for (int T = 0; T < N; T++) {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++) {
                    if (i <= T) {
                        left += arr[i];
                    } else {
                        right += arr[i];
                    }
                }
                if (diff > (Math.abs(left - right))) {
                    diff = (Math.abs(left - right));
                }
            }
            out.println(diff);

        }

    }
}

