import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] list = new int[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        }
        int sum = IntStream.of(list).sum();
        int min = (int)10e5;
        int mid = 0;
        for(int i=1; i<N; i++) {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        }
        System.out.println(min);
    }
} import java.util.Scanner; Scanner java.util import java.util.stream.IntStream; IntStream java.util.stream public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] list = new int[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        }
        int sum = IntStream.of(list).sum();
        int min = (int)10e5;
        int mid = 0;
        for(int i=1; i<N; i++) {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        }
        System.out.println(min);
    }
} Main public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] list = new int[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        }
        int sum = IntStream.of(list).sum();
        int min = (int)10e5;
        int mid = 0;
        for(int i=1; i<N; i++) {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        }
        System.out.println(min);
    } main {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] list = new int[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        }
        int sum = IntStream.of(list).sum();
        int min = (int)10e5;
        int mid = 0;
        for(int i=1; i<N; i++) {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        }
        System.out.println(min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] list = new int[N]; list new int[N] N for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            list[i] = sc.nextInt();
        } {
            list[i] = sc.nextInt();
        } list[i] = sc.nextInt() list[i] list i sc.nextInt() sc.nextInt sc int sum = IntStream.of(list).sum(); sum IntStream.of(list).sum() IntStream.of(list).sum IntStream.of(list) IntStream.of IntStream list int min = (int)10e5; min (int)10e5 int mid = 0; mid 0 for(int i=1; i<N; i++) {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        } int i=1; int i=1; i 1 i<N i N i++ i++ i {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        } {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        } int suml=0; suml 0 for(int j=0; j<i; j++) {
                suml += list[j];
            } int j=0; int j=0; j 0 j<i j i j++ j++ j {
                suml += list[j];
            } {
                suml += list[j];
            } suml += list[j] suml list[j] list j if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            } Math.abs(suml - (sum-suml)) < min Math.abs(suml - (sum-suml)) Math.abs Math suml - (sum-suml) suml (sum-suml) sum suml min {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            } min = Math.abs(suml - (sum-suml)) min Math.abs(suml - (sum-suml)) Math.abs Math suml - (sum-suml) suml (sum-suml) sum suml mid = i mid i System.out.println(min) System.out.println System.out System System.out min String args[] args public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] list = new int[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        }
        int sum = IntStream.of(list).sum();
        int min = (int)10e5;
        int mid = 0;
        for(int i=1; i<N; i++) {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        }
        System.out.println(min);
    }
} public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] list = new int[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        }
        int sum = IntStream.of(list).sum();
        int min = (int)10e5;
        int mid = 0;
        for(int i=1; i<N; i++) {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        }
        System.out.println(min);
    }
} Main
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] list = new int[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        }
        int sum = IntStream.of(list).sum();
        int min = (int)10e5;
        int mid = 0;
        for(int i=1; i<N; i++) {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        }
        System.out.println(min);
    }
}