import java.util.Scanner;
import java.util.ArrayList;


public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        ArrayList<Integer> Array = new ArrayList<Integer>();
        int l,r,abs=10000,temp;

        for(int i = 0; i<num1;i++){
            int num2 = scan.nextInt();
            Array.add(num2);
        }
        for(int i = 0; i<num1;i++){
            l = r = 0;
            for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            }
            if(r > l) temp = r-l;
            else      temp = l-r;
            if(abs > temp)  abs = temp;
        }

        System.out.println(abs);
    }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        ArrayList<Integer> Array = new ArrayList<Integer>();
        int l,r,abs=10000,temp;

        for(int i = 0; i<num1;i++){
            int num2 = scan.nextInt();
            Array.add(num2);
        }
        for(int i = 0; i<num1;i++){
            l = r = 0;
            for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            }
            if(r > l) temp = r-l;
            else      temp = l-r;
            if(abs > temp)  abs = temp;
        }

        System.out.println(abs);
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        ArrayList<Integer> Array = new ArrayList<Integer>();
        int l,r,abs=10000,temp;

        for(int i = 0; i<num1;i++){
            int num2 = scan.nextInt();
            Array.add(num2);
        }
        for(int i = 0; i<num1;i++){
            l = r = 0;
            for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            }
            if(r > l) temp = r-l;
            else      temp = l-r;
            if(abs > temp)  abs = temp;
        }

        System.out.println(abs);
    } main {
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        ArrayList<Integer> Array = new ArrayList<Integer>();
        int l,r,abs=10000,temp;

        for(int i = 0; i<num1;i++){
            int num2 = scan.nextInt();
            Array.add(num2);
        }
        for(int i = 0; i<num1;i++){
            l = r = 0;
            for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            }
            if(r > l) temp = r-l;
            else      temp = l-r;
            if(abs > temp)  abs = temp;
        }

        System.out.println(abs);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int num1 = scan.nextInt(); num1 scan.nextInt() scan.nextInt scan ArrayList<Integer> Array = new ArrayList<Integer>(); Array new ArrayList<Integer>() int l l r r abs=10000 abs 10000 temp; temp for(int i = 0; i<num1;i++){
            int num2 = scan.nextInt();
            Array.add(num2);
        } int i = 0; int i = 0; i 0 i<num1 i num1 i++ i++ i {
            int num2 = scan.nextInt();
            Array.add(num2);
        } {
            int num2 = scan.nextInt();
            Array.add(num2);
        } int num2 = scan.nextInt(); num2 scan.nextInt() scan.nextInt scan Array.add(num2) Array.add Array num2 for(int i = 0; i<num1;i++){
            l = r = 0;
            for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            }
            if(r > l) temp = r-l;
            else      temp = l-r;
            if(abs > temp)  abs = temp;
        } int i = 0; int i = 0; i 0 i<num1 i num1 i++ i++ i {
            l = r = 0;
            for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            }
            if(r > l) temp = r-l;
            else      temp = l-r;
            if(abs > temp)  abs = temp;
        } {
            l = r = 0;
            for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            }
            if(r > l) temp = r-l;
            else      temp = l-r;
            if(abs > temp)  abs = temp;
        } l = r = 0 l r = 0 r 0 for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            } int j = 0; int j = 0; j 0 j<num1 j num1 j++ j++ j {
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            } {
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            } if(j <= i)  l += Array.get(j);
                else        r += Array.get(j); j <= i j i l += Array.get(j) l Array.get(j) Array.get Array j r += Array.get(j) r Array.get(j) Array.get Array j if(r > l) temp = r-l;
            else      temp = l-r; r > l r l temp = r-l temp r-l r l temp = l-r temp l-r l r if(abs > temp)  abs = temp; abs > temp abs temp abs = temp abs temp System.out.println(abs) System.out.println System.out System System.out abs String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        ArrayList<Integer> Array = new ArrayList<Integer>();
        int l,r,abs=10000,temp;

        for(int i = 0; i<num1;i++){
            int num2 = scan.nextInt();
            Array.add(num2);
        }
        for(int i = 0; i<num1;i++){
            l = r = 0;
            for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            }
            if(r > l) temp = r-l;
            else      temp = l-r;
            if(abs > temp)  abs = temp;
        }

        System.out.println(abs);
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        ArrayList<Integer> Array = new ArrayList<Integer>();
        int l,r,abs=10000,temp;

        for(int i = 0; i<num1;i++){
            int num2 = scan.nextInt();
            Array.add(num2);
        }
        for(int i = 0; i<num1;i++){
            l = r = 0;
            for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            }
            if(r > l) temp = r-l;
            else      temp = l-r;
            if(abs > temp)  abs = temp;
        }

        System.out.println(abs);
    }
} Main
import java.util.Scanner;
import java.util.ArrayList;


public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        ArrayList<Integer> Array = new ArrayList<Integer>();
        int l,r,abs=10000,temp;

        for(int i = 0; i<num1;i++){
            int num2 = scan.nextInt();
            Array.add(num2);
        }
        for(int i = 0; i<num1;i++){
            l = r = 0;
            for(int j = 0; j<num1;j++){
                if(j <= i)  l += Array.get(j);
                else        r += Array.get(j);
            }
            if(r > l) temp = r-l;
            else      temp = l-r;
            if(abs > temp)  abs = temp;
        }

        System.out.println(abs);
    }
}