import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int numbers[] = new int[n];
        int total = 0;
        int count = 0;
        int min = n + 1;
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(sc.next());
            total += numbers[i];
        }
        for(int i = 0 ; i < n; i++){
            count += numbers[i];
            int temp = Math.abs(total - (count * 2) );
            if(temp < min) min = temp;
        }
        System.out.println(min);
        
    }
    
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int numbers[] = new int[n];
        int total = 0;
        int count = 0;
        int min = n + 1;
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(sc.next());
            total += numbers[i];
        }
        for(int i = 0 ; i < n; i++){
            count += numbers[i];
            int temp = Math.abs(total - (count * 2) );
            if(temp < min) min = temp;
        }
        System.out.println(min);
        
    }
    
} Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int numbers[] = new int[n];
        int total = 0;
        int count = 0;
        int min = n + 1;
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(sc.next());
            total += numbers[i];
        }
        for(int i = 0 ; i < n; i++){
            count += numbers[i];
            int temp = Math.abs(total - (count * 2) );
            if(temp < min) min = temp;
        }
        System.out.println(min);
        
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int numbers[] = new int[n];
        int total = 0;
        int count = 0;
        int min = n + 1;
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(sc.next());
            total += numbers[i];
        }
        for(int i = 0 ; i < n; i++){
            count += numbers[i];
            int temp = Math.abs(total - (count * 2) );
            if(temp < min) min = temp;
        }
        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 numbers[] = new int[n]; numbers new int[n] n int total = 0; total 0 int count = 0; count 0 int min = n + 1; min n + 1 n 1 for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(sc.next());
            total += numbers[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            numbers[i] = Integer.parseInt(sc.next());
            total += numbers[i];
        } {
            numbers[i] = Integer.parseInt(sc.next());
            total += numbers[i];
        } numbers[i] = Integer.parseInt(sc.next()) numbers[i] numbers i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc total += numbers[i] total numbers[i] numbers i for(int i = 0 ; i < n; i++){
            count += numbers[i];
            int temp = Math.abs(total - (count * 2) );
            if(temp < min) min = temp;
        } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
            count += numbers[i];
            int temp = Math.abs(total - (count * 2) );
            if(temp < min) min = temp;
        } {
            count += numbers[i];
            int temp = Math.abs(total - (count * 2) );
            if(temp < min) min = temp;
        } count += numbers[i] count numbers[i] numbers i int temp = Math.abs(total - (count * 2) ); temp Math.abs(total - (count * 2) ) Math.abs Math total - (count * 2) total (count * 2) count 2 if(temp < min) min = temp; temp < min temp min min = temp min temp System.out.println(min) System.out.println System.out System System.out min String args[] args
import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int numbers[] = new int[n];
        int total = 0;
        int count = 0;
        int min = n + 1;
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(sc.next());
            total += numbers[i];
        }
        for(int i = 0 ; i < n; i++){
            count += numbers[i];
            int temp = Math.abs(total - (count * 2) );
            if(temp < min) min = temp;
        }
        System.out.println(min);
        
    }
    
}