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);
    }
} import java.util.*; util.* java 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);
    }
} 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);
    } main {
        // 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);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] w = new int[n]; w new int[n] n int t = 1; t 1 sc.nextLine() sc.nextLine sc int[] s_1=new int[n]; s_1 new int[n] n int[] s_2 =new int[n]; s_2 new int[n] n int min = 0; min 0 for(int j =0; j < n;j++){
            w[j]=sc.nextInt();
        } int j =0; int j =0; j 0 j < n j n j++ j++ j {
            w[j]=sc.nextInt();
        } {
            w[j]=sc.nextInt();
        } w[j]=sc.nextInt() w[j] w j sc.nextInt() sc.nextInt sc 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];
            }
            
        }
        } int j =0; int j =0; j 0 j < n j n j++ j++ 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];
            }
            
        }
        } {
            
        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];
            }
            
        }
        } 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];
            }
            
        } int i =0; int i =0; i 0 i < n i n i++ i++ i {
            if(i <= j){
                //s_1を求める
                s_1[j] = s_1[j] +w[i];
            } else {
                s_2[j] = s_2[j] + w[i];
            }
            
        } {
            if(i <= j){
                //s_1を求める
                s_1[j] = s_1[j] +w[i];
            } else {
                s_2[j] = s_2[j] + w[i];
            }
            
        } if(i <= j){
                //s_1を求める
                s_1[j] = s_1[j] +w[i];
            } else {
                s_2[j] = s_2[j] + w[i];
            } i <= j i j {
                //s_1を求める
                s_1[j] = s_1[j] +w[i];
            } s_1[j] = s_1[j] +w[i] s_1[j] s_1 j s_1[j] +w[i] s_1[j] s_1 j w[i] w i {
                s_2[j] = s_2[j] + w[i];
            } s_2[j] = s_2[j] + w[i] s_2[j] s_2 j s_2[j] + w[i] s_2[j] s_2 j w[i] w i min=Math.abs(s_1[0]-s_2[0]) min Math.abs(s_1[0]-s_2[0]) Math.abs Math s_1[0]-s_2[0] s_1[0] s_1 0 s_2[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]);
        }
        } int k =0; int k =0; k 0 k < n k n k++ k++ k {
        if(min > Math.abs(s_1[k]-s_2[k])){
            min = Math.abs(s_1[k]-s_2[k]);
        }
        } {
        if(min > Math.abs(s_1[k]-s_2[k])){
            min = Math.abs(s_1[k]-s_2[k]);
        }
        } if(min > Math.abs(s_1[k]-s_2[k])){
            min = Math.abs(s_1[k]-s_2[k]);
        } min > Math.abs(s_1[k]-s_2[k]) min Math.abs(s_1[k]-s_2[k]) Math.abs Math s_1[k]-s_2[k] s_1[k] s_1 k s_2[k] s_2 k {
            min = Math.abs(s_1[k]-s_2[k]);
        } min = Math.abs(s_1[k]-s_2[k]) min Math.abs(s_1[k]-s_2[k]) Math.abs Math s_1[k]-s_2[k] s_1[k] s_1 k s_2[k] s_2 k System.out.println(min) System.out.println System.out System System.out min String[] args args 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);
    }
} 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);
    }
} Main
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);
    }
}
