import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int n = sc.nextInt();
    int s1 = 0;
    int s2 = 0;
    int min = 10001;

    for(int i = 0; i < n; i++){
        list.add(sc.nextInt());
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        }

        if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        }

        s1 = 0;
        s2 = 0;
    }

    System.out.println(min);

    



    



   
    





}
} import java.io.BufferedReader; BufferedReader java.io import java.io.*; io.* java import java.util.*; util.* java import java.util.ArrayList; ArrayList java.util import java.util.Iterator; Iterator java.util import java.util.List; List java.util import java.util.Collections; Collections java.util import java.util.Arrays; Arrays java.util public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int n = sc.nextInt();
    int s1 = 0;
    int s2 = 0;
    int min = 10001;

    for(int i = 0; i < n; i++){
        list.add(sc.nextInt());
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        }

        if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        }

        s1 = 0;
        s2 = 0;
    }

    System.out.println(min);

    



    



   
    





}
} Main public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int n = sc.nextInt();
    int s1 = 0;
    int s2 = 0;
    int min = 10001;

    for(int i = 0; i < n; i++){
        list.add(sc.nextInt());
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        }

        if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        }

        s1 = 0;
        s2 = 0;
    }

    System.out.println(min);

    



    



   
    





} main {
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int n = sc.nextInt();
    int s1 = 0;
    int s2 = 0;
    int min = 10001;

    for(int i = 0; i < n; i++){
        list.add(sc.nextInt());
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        }

        if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        }

        s1 = 0;
        s2 = 0;
    }

    System.out.println(min);

    



    



   
    





} final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final List<Integer> list = new ArrayList<>(); list new ArrayList<>() int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int s1 = 0; s1 0 int s2 = 0; s2 0 int min = 10001; min 10001 for(int i = 0; i < n; i++){
        list.add(sc.nextInt());
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        list.add(sc.nextInt());
    } {
        list.add(sc.nextInt());
    } list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc for(int i = 0; i < n; i++){
        for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        }

        if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        }

        s1 = 0;
        s2 = 0;
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        }

        if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        }

        s1 = 0;
        s2 = 0;
    } {
        for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        }

        if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        }

        s1 = 0;
        s2 = 0;
    } for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        } {
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        } if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            } j <= i j i {
                s1 += list.get(j);
            } s1 += list.get(j) s1 list.get(j) list.get list j {
                s2 += list.get(j);
            } s2 += list.get(j) s2 list.get(j) list.get list j if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        } min >= Math.abs(s1 - s2) min Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 {
            min = Math.abs(s1 - s2); 
        } min = Math.abs(s1 - s2) min Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 s1 = 0 s1 0 s2 = 0 s2 0 System.out.println(min) System.out.println System.out System System.out min final String[] args args public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int n = sc.nextInt();
    int s1 = 0;
    int s2 = 0;
    int min = 10001;

    for(int i = 0; i < n; i++){
        list.add(sc.nextInt());
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        }

        if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        }

        s1 = 0;
        s2 = 0;
    }

    System.out.println(min);

    



    



   
    





}
} public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int n = sc.nextInt();
    int s1 = 0;
    int s2 = 0;
    int min = 10001;

    for(int i = 0; i < n; i++){
        list.add(sc.nextInt());
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        }

        if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        }

        s1 = 0;
        s2 = 0;
    }

    System.out.println(min);

    



    



   
    





}
} Main
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int n = sc.nextInt();
    int s1 = 0;
    int s2 = 0;
    int min = 10001;

    for(int i = 0; i < n; i++){
        list.add(sc.nextInt());
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n ; j++){
            if(j <= i){
                s1 += list.get(j);
            }else{
                s2 += list.get(j);
            }
        }

        if(min >= Math.abs(s1 - s2)){
            min = Math.abs(s1 - s2); 
        }

        s1 = 0;
        s2 = 0;
    }

    System.out.println(min);

    



    



   
    





}
}