import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int[] W = new int[N];

        int sum = 0;
        for(int i=0; i<N; i++){
            W[i] = nextInt();
            sum += W[i];
        }

        int min = sum;
        int sum2 = 0;
        for(int i=0; i<N-1; i++){
            sum2 += W[i];
            min = Math.min(Math.abs(sum-sum2 - sum2), min);
        }

        println(min);
    }

    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

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

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.*; util.* java public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int[] W = new int[N];

        int sum = 0;
        for(int i=0; i<N; i++){
            W[i] = nextInt();
            sum += W[i];
        }

        int min = sum;
        int sum2 = 0;
        for(int i=0; i<N-1; i++){
            sum2 += W[i];
            min = Math.min(Math.abs(sum-sum2 - sum2), min);
        }

        println(min);
    }

    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

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

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
} Main static String br = System.getProperty("line.separator"); br System.getProperty("line.separator") System.getProperty System "line.separator" static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) public static void main(String[] args) {
        int N = nextInt();
        int[] W = new int[N];

        int sum = 0;
        for(int i=0; i<N; i++){
            W[i] = nextInt();
            sum += W[i];
        }

        int min = sum;
        int sum2 = 0;
        for(int i=0; i<N-1; i++){
            sum2 += W[i];
            min = Math.min(Math.abs(sum-sum2 - sum2), min);
        }

        println(min);
    } main {
        int N = nextInt();
        int[] W = new int[N];

        int sum = 0;
        for(int i=0; i<N; i++){
            W[i] = nextInt();
            sum += W[i];
        }

        int min = sum;
        int sum2 = 0;
        for(int i=0; i<N-1; i++){
            sum2 += W[i];
            min = Math.min(Math.abs(sum-sum2 - sum2), min);
        }

        println(min);
    } int N = nextInt(); N nextInt() nextInt int[] W = new int[N]; W new int[N] N int sum = 0; sum 0 for(int i=0; i<N; i++){
            W[i] = nextInt();
            sum += W[i];
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            W[i] = nextInt();
            sum += W[i];
        } {
            W[i] = nextInt();
            sum += W[i];
        } W[i] = nextInt() W[i] W i nextInt() nextInt sum += W[i] sum W[i] W i int min = sum; min sum int sum2 = 0; sum2 0 for(int i=0; i<N-1; i++){
            sum2 += W[i];
            min = Math.min(Math.abs(sum-sum2 - sum2), min);
        } int i=0; int i=0; i 0 i<N-1 i N-1 N 1 i++ i++ i {
            sum2 += W[i];
            min = Math.min(Math.abs(sum-sum2 - sum2), min);
        } {
            sum2 += W[i];
            min = Math.min(Math.abs(sum-sum2 - sum2), min);
        } sum2 += W[i] sum2 W[i] W i min = Math.min(Math.abs(sum-sum2 - sum2), min) min Math.min(Math.abs(sum-sum2 - sum2), min) Math.min Math Math.abs(sum-sum2 - sum2) Math.abs Math sum-sum2 - sum2 sum-sum2 - sum2 sum sum2 sum2 min println(min) println min String[] args args //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    } lcm {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    } long temp; temp long c = a; c a c *= b c b while((temp = a%b)!=0) {
            a = b;
            b = temp;
        } (temp = a%b)!=0 (temp = a%b) temp a%b a b 0 {
            a = b;
            b = temp;
        } a = b a b b = temp b temp return (c/b); (c/b) c b long a a long b b static int nextInt() {
        return Integer.parseInt(next());
    } nextInt {
        return Integer.parseInt(next());
    } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next static Long nextLong() {
        return Long.parseLong(next());
    } nextLong {
        return Long.parseLong(next());
    } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next static String next() {
        return sc.next();
    } next {
        return sc.next();
    } return sc.next(); sc.next() sc.next sc static String nextLine(){
        return sc.nextLine();
    } nextLine {
        return sc.nextLine();
    } return sc.nextLine(); sc.nextLine() sc.nextLine sc static void println(Object o) {
        out.println(o);
        out.flush();
    } println {
        out.println(o);
        out.flush();
    } out.println(o) out.println out o out.flush() out.flush out Object o o static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    } print {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    } PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) out.print(o) out.print out o out.flush() out.flush out Object o o public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int[] W = new int[N];

        int sum = 0;
        for(int i=0; i<N; i++){
            W[i] = nextInt();
            sum += W[i];
        }

        int min = sum;
        int sum2 = 0;
        for(int i=0; i<N-1; i++){
            sum2 += W[i];
            min = Math.min(Math.abs(sum-sum2 - sum2), min);
        }

        println(min);
    }

    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

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

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
} public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int[] W = new int[N];

        int sum = 0;
        for(int i=0; i<N; i++){
            W[i] = nextInt();
            sum += W[i];
        }

        int min = sum;
        int sum2 = 0;
        for(int i=0; i<N-1; i++){
            sum2 += W[i];
            min = Math.min(Math.abs(sum-sum2 - sum2), min);
        }

        println(min);
    }

    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

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

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
} Main
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int[] W = new int[N];

        int sum = 0;
        for(int i=0; i<N; i++){
            W[i] = nextInt();
            sum += W[i];
        }

        int min = sum;
        int sum2 = 0;
        for(int i=0; i<N-1; i++){
            sum2 += W[i];
            min = Math.min(Math.abs(sum-sum2 - sum2), min);
        }

        println(min);
    }

    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

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

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}
