import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        int[] w = new int[N];
        int sum = 0;
        for(int i = 0; i < N; i++) {
            w[i] = Integer.parseInt(sc.next());
            sum += w[i];
        }
        
        int s1 = 0;
        for(int i = 0; i < N; i++) {
            s1 += w[i];
            if(s1 >= sum/2) {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            }
        }
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        int[] w = new int[N];
        int sum = 0;
        for(int i = 0; i < N; i++) {
            w[i] = Integer.parseInt(sc.next());
            sum += w[i];
        }
        
        int s1 = 0;
        for(int i = 0; i < N; i++) {
            s1 += w[i];
            if(s1 >= sum/2) {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            }
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        int[] w = new int[N];
        int sum = 0;
        for(int i = 0; i < N; i++) {
            w[i] = Integer.parseInt(sc.next());
            sum += w[i];
        }
        
        int s1 = 0;
        for(int i = 0; i < N; i++) {
            s1 += w[i];
            if(s1 >= sum/2) {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        int[] w = new int[N];
        int sum = 0;
        for(int i = 0; i < N; i++) {
            w[i] = Integer.parseInt(sc.next());
            sum += w[i];
        }
        
        int s1 = 0;
        for(int i = 0; i < N; i++) {
            s1 += w[i];
            if(s1 >= sum/2) {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] w = new int[N]; w new int[N] N int sum = 0; sum 0 for(int i = 0; i < N; i++) {
            w[i] = Integer.parseInt(sc.next());
            sum += w[i];
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            w[i] = Integer.parseInt(sc.next());
            sum += w[i];
        } {
            w[i] = Integer.parseInt(sc.next());
            sum += w[i];
        } w[i] = Integer.parseInt(sc.next()) w[i] w i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sum += w[i] sum w[i] w i int s1 = 0; s1 0 for(int i = 0; i < N; i++) {
            s1 += w[i];
            if(s1 >= sum/2) {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            s1 += w[i];
            if(s1 >= sum/2) {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            }
        } {
            s1 += w[i];
            if(s1 >= sum/2) {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            }
        } s1 += w[i] s1 w[i] w i if(s1 >= sum/2) {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            } s1 >= sum/2 s1 sum/2 sum 2 {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            } if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                } s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i]) s1 - (sum-s1) s1 (sum-s1) sum s1 (sum-s1+w[i]) - (s1-w[i]) (sum-s1+w[i]) sum-s1 sum s1 w[i] w i (s1-w[i]) s1 w[i] w i {
                    System.out.println(s1 - (sum-s1));
                } System.out.println(s1 - (sum-s1)) System.out.println System.out System System.out s1 - (sum-s1) s1 (sum-s1) sum s1 {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                } System.out.println((sum-s1+w[i]) - (s1-w[i])) System.out.println System.out System System.out (sum-s1+w[i]) - (s1-w[i]) (sum-s1+w[i]) sum-s1 sum s1 w[i] w i (s1-w[i]) s1 w[i] w i break; String[] args args
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        int[] w = new int[N];
        int sum = 0;
        for(int i = 0; i < N; i++) {
            w[i] = Integer.parseInt(sc.next());
            sum += w[i];
        }
        
        int s1 = 0;
        for(int i = 0; i < N; i++) {
            s1 += w[i];
            if(s1 >= sum/2) {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            }
        }
    }
}