import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i=0; i<N; i++){
            W[i] = sc.nextInt();

        }
        sc.close();

        int first=0,end=0,all=0;
        int min = Integer.MAX_VALUE;
        int a=0,b=0;

        for (int i=0; i<N; i++){
            all += W[i];
        }
        for (int i=0; i<N; i++){
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        }


        System .out.println(Math.abs(Math.abs(a - b)));

    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i=0; i<N; i++){
            W[i] = sc.nextInt();

        }
        sc.close();

        int first=0,end=0,all=0;
        int min = Integer.MAX_VALUE;
        int a=0,b=0;

        for (int i=0; i<N; i++){
            all += W[i];
        }
        for (int i=0; i<N; i++){
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        }


        System .out.println(Math.abs(Math.abs(a - b)));

    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i=0; i<N; i++){
            W[i] = sc.nextInt();

        }
        sc.close();

        int first=0,end=0,all=0;
        int min = Integer.MAX_VALUE;
        int a=0,b=0;

        for (int i=0; i<N; i++){
            all += W[i];
        }
        for (int i=0; i<N; i++){
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        }


        System .out.println(Math.abs(Math.abs(a - b)));

    } main {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i=0; i<N; i++){
            W[i] = sc.nextInt();

        }
        sc.close();

        int first=0,end=0,all=0;
        int min = Integer.MAX_VALUE;
        int a=0,b=0;

        for (int i=0; i<N; i++){
            all += W[i];
        }
        for (int i=0; i<N; i++){
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        }


        System .out.println(Math.abs(Math.abs(a - b)));

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] W = new int[N]; W new int[N] N for (int i=0; i<N; i++){
            W[i] = sc.nextInt();

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

        } {
            W[i] = sc.nextInt();

        } W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc sc.close() sc.close sc int first=0 first 0 end=0 end 0 all=0; all 0 int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE int a=0 a 0 b=0; b 0 for (int i=0; i<N; i++){
            all += W[i];
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            all += W[i];
        } {
            all += W[i];
        } all += W[i] all W[i] W i for (int i=0; i<N; i++){
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        } {
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        } first += W[i] first W[i] W i end = all - first end all - first all first if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            } Math.abs(first - end) < min Math.abs(first - end) Math.abs Math first - end first end min {
                min = Math.abs(first - end);
                a = first;
                b = end;
            } min = Math.abs(first - end) min Math.abs(first - end) Math.abs Math first - end first end a = first a first b = end b end {
                break;
            } break; System .out.println(Math.abs(Math.abs(a - b))) System .out.println System .out System System .out Math.abs(Math.abs(a - b)) Math.abs Math Math.abs(a - b) Math.abs Math a - b a b String[] args args public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i=0; i<N; i++){
            W[i] = sc.nextInt();

        }
        sc.close();

        int first=0,end=0,all=0;
        int min = Integer.MAX_VALUE;
        int a=0,b=0;

        for (int i=0; i<N; i++){
            all += W[i];
        }
        for (int i=0; i<N; i++){
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        }


        System .out.println(Math.abs(Math.abs(a - b)));

    }
} public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i=0; i<N; i++){
            W[i] = sc.nextInt();

        }
        sc.close();

        int first=0,end=0,all=0;
        int min = Integer.MAX_VALUE;
        int a=0,b=0;

        for (int i=0; i<N; i++){
            all += W[i];
        }
        for (int i=0; i<N; i++){
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        }


        System .out.println(Math.abs(Math.abs(a - b)));

    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i=0; i<N; i++){
            W[i] = sc.nextInt();

        }
        sc.close();

        int first=0,end=0,all=0;
        int min = Integer.MAX_VALUE;
        int a=0,b=0;

        for (int i=0; i<N; i++){
            all += W[i];
        }
        for (int i=0; i<N; i++){
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        }


        System .out.println(Math.abs(Math.abs(a - b)));

    }
}
