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
 *
 * @author teiwa
 */
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] w = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            }

            int sumMin = Integer.MAX_VALUE;
            int answer = 0;
            for (int i = 1; i < n; i++) {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            }
            out.print(answer);
        }

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] w = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            }

            int sumMin = Integer.MAX_VALUE;
            int answer = 0;
            for (int i = 1; i < n; i++) {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            }
            out.print(answer);
        }

    }
} 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);
        TaskB solver = new TaskB();
        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);
        TaskB solver = new TaskB();
        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) TaskB solver = new TaskB(); solver new TaskB() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] w = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            }

            int sumMin = Integer.MAX_VALUE;
            int answer = 0;
            for (int i = 1; i < n; i++) {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            }
            out.print(answer);
        }

    } TaskB public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] w = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            }

            int sumMin = Integer.MAX_VALUE;
            int answer = 0;
            for (int i = 1; i < n; i++) {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            }
            out.print(answer);
        } solve {
            int n = in.nextInt();
            int[] w = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            }

            int sumMin = Integer.MAX_VALUE;
            int answer = 0;
            for (int i = 1; i < n; i++) {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            }
            out.print(answer);
        } int n = in.nextInt(); n in.nextInt() in.nextInt in int[] w = new int[n]; w new int[n] n for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                w[i] = in.nextInt();
            } {
                w[i] = in.nextInt();
            } w[i] = in.nextInt() w[i] w i in.nextInt() in.nextInt in int sumMin = Integer.MAX_VALUE; sumMin Integer.MAX_VALUE Integer Integer.MAX_VALUE int answer = 0; answer 0 for (int i = 1; i < n; i++) {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            } {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            } int leftSum = 0; leftSum 0 for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                } int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
                    leftSum += w[j];
                } {
                    leftSum += w[j];
                } leftSum += w[j] leftSum w[j] w j int rightSum = 0; rightSum 0 for (int j = i; j < n; j++) {
                    rightSum += w[j];
                } int j = i; int j = i; j i j < n j n j++ j++ j {
                    rightSum += w[j];
                } {
                    rightSum += w[j];
                } rightSum += w[j] rightSum w[j] w j int diff = Math.abs(leftSum - rightSum); diff Math.abs(leftSum - rightSum) Math.abs Math leftSum - rightSum leftSum rightSum if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                } diff < sumMin diff sumMin {
                    sumMin = diff;
                    answer = diff;
                } sumMin = diff sumMin diff answer = diff answer diff out.print(answer) out.print out answer 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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] w = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            }

            int sumMin = Integer.MAX_VALUE;
            int answer = 0;
            for (int i = 1; i < n; i++) {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            }
            out.print(answer);
        }

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] w = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            }

            int sumMin = Integer.MAX_VALUE;
            int answer = 0;
            for (int i = 1; i < n; i++) {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            }
            out.print(answer);
        }

    }
} 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
 *
 * @author teiwa
 */
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] w = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            }

            int sumMin = Integer.MAX_VALUE;
            int answer = 0;
            for (int i = 1; i < n; i++) {
                // 左側
                int leftSum = 0;
                for (int j = 0; j < i; j++) {
                    leftSum += w[j];
                }
                // 右側
                int rightSum = 0;
                for (int j = i; j < n; j++) {
                    rightSum += w[j];
                }
                // 差
                int diff = Math.abs(leftSum - rightSum);
                // それまでで最小なら
                if (diff < sumMin) {
                    sumMin = diff;
                    answer = diff;
                }
            }
            out.print(answer);
        }

    }
}

