import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] ws = new int[n + 1];
        int sum = 0;
        ws[0] = 0;
        for (int i = 1; i <= n; i++) {
            int w = in.nextInt();
            sum += w;
            ws[i] = w + ws[i - 1];
        }

        int ans = 1 << 29;
        for (int i = 1; i < n; i++) {
            ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i]));
        }

        out.println(ans);
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] ws = new int[n + 1];
        int sum = 0;
        ws[0] = 0;
        for (int i = 1; i <= n; i++) {
            int w = in.nextInt();
            sum += w;
            ws[i] = w + ws[i - 1];
        }

        int ans = 1 << 29;
        for (int i = 1; i < n; i++) {
            ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i]));
        }

        out.println(ans);
    }
} Main public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    } main {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    } try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        } {
            new Main().solve(in, out);
            out.flush();
        } InputReader in = new InputReader() InputReader in = new InputReader() new InputReader() PrintWriter out = new PrintWriter(System.out) PrintWriter out = new PrintWriter(System.out) new PrintWriter(System.out) new Main().solve(in, out) new Main().solve new Main() in out out.flush() out.flush out String[] args args void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] ws = new int[n + 1];
        int sum = 0;
        ws[0] = 0;
        for (int i = 1; i <= n; i++) {
            int w = in.nextInt();
            sum += w;
            ws[i] = w + ws[i - 1];
        }

        int ans = 1 << 29;
        for (int i = 1; i < n; i++) {
            ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i]));
        }

        out.println(ans);
    } solve {
        int n = in.nextInt();
        int[] ws = new int[n + 1];
        int sum = 0;
        ws[0] = 0;
        for (int i = 1; i <= n; i++) {
            int w = in.nextInt();
            sum += w;
            ws[i] = w + ws[i - 1];
        }

        int ans = 1 << 29;
        for (int i = 1; i < n; i++) {
            ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i]));
        }

        out.println(ans);
    } int n = in.nextInt(); n in.nextInt() in.nextInt in int[] ws = new int[n + 1]; ws new int[n + 1] n + 1 n 1 int sum = 0; sum 0 ws[0] = 0 ws[0] ws 0 0 for (int i = 1; i <= n; i++) {
            int w = in.nextInt();
            sum += w;
            ws[i] = w + ws[i - 1];
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            int w = in.nextInt();
            sum += w;
            ws[i] = w + ws[i - 1];
        } {
            int w = in.nextInt();
            sum += w;
            ws[i] = w + ws[i - 1];
        } int w = in.nextInt(); w in.nextInt() in.nextInt in sum += w sum w ws[i] = w + ws[i - 1] ws[i] ws i w + ws[i - 1] w ws[i - 1] ws i - 1 i 1 int ans = 1 << 29; ans 1 << 29 1 29 for (int i = 1; i < n; i++) {
            ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i]));
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i]));
        } {
            ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i]));
        } ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i])) ans Math.min(ans, Math.abs((sum - ws[i]) - ws[i])) Math.min Math ans Math.abs((sum - ws[i]) - ws[i]) Math.abs Math (sum - ws[i]) - ws[i] (sum - ws[i]) sum ws[i] ws i ws[i] ws i out.println(ans) out.println out ans InputReader in in PrintWriter out out class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
} InputReader private final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String next() {
        return this.sc.next();
    } next {
        return this.sc.next();
    } return this.sc.next(); this.sc.next() this.sc.next this.sc this this.sc int nextInt() {
        return Integer.parseInt(this.sc.next());
    } nextInt {
        return Integer.parseInt(this.sc.next());
    } return Integer.parseInt(this.sc.next()); Integer.parseInt(this.sc.next()) Integer.parseInt Integer this.sc.next() this.sc.next this.sc this this.sc long nextLong() {
        return Long.parseLong(this.sc.next());
    } nextLong {
        return Long.parseLong(this.sc.next());
    } return Long.parseLong(this.sc.next()); Long.parseLong(this.sc.next()) Long.parseLong Long this.sc.next() this.sc.next this.sc this this.sc double nextDouble() {
        return Double.parseDouble(this.sc.next());
    } nextDouble {
        return Double.parseDouble(this.sc.next());
    } return Double.parseDouble(this.sc.next()); Double.parseDouble(this.sc.next()) Double.parseDouble Double this.sc.next() this.sc.next this.sc this this.sc @Override
    public void close() {
        this.sc.close();
    } close {
        this.sc.close();
    } this.sc.close() this.sc.close this.sc this this.sc AutoCloseable public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] ws = new int[n + 1];
        int sum = 0;
        ws[0] = 0;
        for (int i = 1; i <= n; i++) {
            int w = in.nextInt();
            sum += w;
            ws[i] = w + ws[i - 1];
        }

        int ans = 1 << 29;
        for (int i = 1; i < n; i++) {
            ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i]));
        }

        out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] ws = new int[n + 1];
        int sum = 0;
        ws[0] = 0;
        for (int i = 1; i <= n; i++) {
            int w = in.nextInt();
            sum += w;
            ws[i] = w + ws[i - 1];
        }

        int ans = 1 << 29;
        for (int i = 1; i < n; i++) {
            ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i]));
        }

        out.println(ans);
    }
} Main
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] ws = new int[n + 1];
        int sum = 0;
        ws[0] = 0;
        for (int i = 1; i <= n; i++) {
            int w = in.nextInt();
            sum += w;
            ws[i] = w + ws[i - 1];
        }

        int ans = 1 << 29;
        for (int i = 1; i < n; i++) {
            ans = Math.min(ans, Math.abs((sum - ws[i]) - ws[i]));
        }

        out.println(ans);
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
}
