import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        /**
         *入力部
         **/
        int n = sc.nextInt();
        int[] w = new int[n];
        int t = 1;
        sc.nextLine();
        int[] s_1=new int[n];
        int[] s_2 =new int[n];
        int min = 0;
        for(int j =0; j < n;j++){
            w[j]=sc.nextInt();
        }
        //どのtでS_1-S_2が最小となるか
        for(int j =0; j < n;j++){
            
        for(int i =0;i < n;i++){
            if(i <= j){
                //s_1を求める
                s_1[j] = s_1[j] +w[i];
            } else {
                s_2[j] = s_2[j] + w[i];
            }
            
        }
        }
        min=Math.abs(s_1[0]-s_2[0]);
        for(int k =0; k < n;k++){
        if(min > Math.abs(s_1[k]-s_2[k])){
            min = Math.abs(s_1[k]-s_2[k]);
        }
        }
        
        System.out.println(min);
    }
}

/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