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

    static class BBalance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            int cur = 0;
            int prev = 0;
            for (int i = 0; i < n; i++) {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            }

        }

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

    static class BBalance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            int cur = 0;
            int prev = 0;
            for (int i = 0; i < n; i++) {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            }

        }

    }
} 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);
        BBalance solver = new BBalance();
        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);
        BBalance solver = new BBalance();
        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) BBalance solver = new BBalance(); solver new BBalance() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class BBalance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            int cur = 0;
            int prev = 0;
            for (int i = 0; i < n; i++) {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            }

        }

    } BBalance public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            int cur = 0;
            int prev = 0;
            for (int i = 0; i < n; i++) {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            }

        } solve {
            int n = in.nextInt();
            int[] arr = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            int cur = 0;
            int prev = 0;
            for (int i = 0; i < n; i++) {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            }

        } int n = in.nextInt(); n in.nextInt() in.nextInt in int[] arr = new int[n]; arr new int[n] n int sum = 0; sum 0 for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                arr[i] = in.nextInt();
                sum += arr[i];
            } {
                arr[i] = in.nextInt();
                sum += arr[i];
            } arr[i] = in.nextInt() arr[i] arr i in.nextInt() in.nextInt in sum += arr[i] sum arr[i] arr i int cur = 0; cur 0 int prev = 0; prev 0 for (int i = 0; i < n; i++) {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            } {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            } prev = cur prev cur cur += arr[i] cur arr[i] arr i if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                } 2 * cur >= sum 2 * cur 2 cur sum {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                } out.println(Math.min((2 * cur - sum), (sum - 2 * prev))) out.println out Math.min((2 * cur - sum), (sum - 2 * prev)) Math.min Math (2 * cur - sum) 2 * cur 2 cur sum (sum - 2 * prev) sum 2 * prev 2 prev break; 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);
        BBalance solver = new BBalance();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBalance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            int cur = 0;
            int prev = 0;
            for (int i = 0; i < n; i++) {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            }

        }

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

    static class BBalance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            int cur = 0;
            int prev = 0;
            for (int i = 0; i < n; i++) {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            }

        }

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

    static class BBalance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            int cur = 0;
            int prev = 0;
            for (int i = 0; i < n; i++) {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            }

        }

    }
}

