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);
    }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz