import java.io.*;
import java.util.*;

public class Main{
    
    public static void main(String[] arg){
        Scanner scan =new Scanner(System.in);
        int n=scan.nextInt();

        ArrayList<Integer> W = new ArrayList<Integer>();

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

        int sum=0;
        for(Integer temp:W){
            sum+=temp;
        }

        int sumk=0;
        int min=Math.abs(sum-2*W.get(0));
        int diffk;

        for(int j=0;j<n-1;j++){
            
            sumk=0;
            for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            }

            diffk=Math.abs(sum-2*sumk);

            if( diffk < min) min=diffk;

        }
        System.out.print(min);
        
  



    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
    
    public static void main(String[] arg){
        Scanner scan =new Scanner(System.in);
        int n=scan.nextInt();

        ArrayList<Integer> W = new ArrayList<Integer>();

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

        int sum=0;
        for(Integer temp:W){
            sum+=temp;
        }

        int sumk=0;
        int min=Math.abs(sum-2*W.get(0));
        int diffk;

        for(int j=0;j<n-1;j++){
            
            sumk=0;
            for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            }

            diffk=Math.abs(sum-2*sumk);

            if( diffk < min) min=diffk;

        }
        System.out.print(min);
        
  



    }
} Main public static void main(String[] arg){
        Scanner scan =new Scanner(System.in);
        int n=scan.nextInt();

        ArrayList<Integer> W = new ArrayList<Integer>();

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

        int sum=0;
        for(Integer temp:W){
            sum+=temp;
        }

        int sumk=0;
        int min=Math.abs(sum-2*W.get(0));
        int diffk;

        for(int j=0;j<n-1;j++){
            
            sumk=0;
            for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            }

            diffk=Math.abs(sum-2*sumk);

            if( diffk < min) min=diffk;

        }
        System.out.print(min);
        
  



    } main {
        Scanner scan =new Scanner(System.in);
        int n=scan.nextInt();

        ArrayList<Integer> W = new ArrayList<Integer>();

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

        int sum=0;
        for(Integer temp:W){
            sum+=temp;
        }

        int sumk=0;
        int min=Math.abs(sum-2*W.get(0));
        int diffk;

        for(int j=0;j<n-1;j++){
            
            sumk=0;
            for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            }

            diffk=Math.abs(sum-2*sumk);

            if( diffk < min) min=diffk;

        }
        System.out.print(min);
        
  



    } Scanner scan =new Scanner(System.in); scan new Scanner(System.in) int n=scan.nextInt(); n scan.nextInt() scan.nextInt scan ArrayList<Integer> W = new ArrayList<Integer>(); W new ArrayList<Integer>() for(int i=0;i<n;i++){
            W.add(scan.nextInt());
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            W.add(scan.nextInt());
        } {
            W.add(scan.nextInt());
        } W.add(scan.nextInt()) W.add W scan.nextInt() scan.nextInt scan int sum=0; sum 0 for(Integer temp:W){
            sum+=temp;
        } Integer temp W {
            sum+=temp;
        } {
            sum+=temp;
        } sum+=temp sum temp int sumk=0; sumk 0 int min=Math.abs(sum-2*W.get(0)); min Math.abs(sum-2*W.get(0)) Math.abs Math sum-2*W.get(0) sum 2*W.get(0) 2 W.get(0) W.get W 0 int diffk; diffk for(int j=0;j<n-1;j++){
            
            sumk=0;
            for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            }

            diffk=Math.abs(sum-2*sumk);

            if( diffk < min) min=diffk;

        } int j=0; int j=0; j 0 j<n-1 j n-1 n 1 j++ j++ j {
            
            sumk=0;
            for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            }

            diffk=Math.abs(sum-2*sumk);

            if( diffk < min) min=diffk;

        } {
            
            sumk=0;
            for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            }

            diffk=Math.abs(sum-2*sumk);

            if( diffk < min) min=diffk;

        } sumk=0 sumk 0 for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            } int k=0; int k=0; k 0 k<=j k j k++ k++ k {
                sumk+=W.get(k);
            } {
                sumk+=W.get(k);
            } sumk+=W.get(k) sumk W.get(k) W.get W k diffk=Math.abs(sum-2*sumk) diffk Math.abs(sum-2*sumk) Math.abs Math sum-2*sumk sum 2*sumk 2 sumk if( diffk < min) min=diffk; diffk < min diffk min min=diffk min diffk System.out.print(min) System.out.print System.out System System.out min String[] arg arg public class Main{
    
    public static void main(String[] arg){
        Scanner scan =new Scanner(System.in);
        int n=scan.nextInt();

        ArrayList<Integer> W = new ArrayList<Integer>();

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

        int sum=0;
        for(Integer temp:W){
            sum+=temp;
        }

        int sumk=0;
        int min=Math.abs(sum-2*W.get(0));
        int diffk;

        for(int j=0;j<n-1;j++){
            
            sumk=0;
            for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            }

            diffk=Math.abs(sum-2*sumk);

            if( diffk < min) min=diffk;

        }
        System.out.print(min);
        
  



    }
} public class Main{
    
    public static void main(String[] arg){
        Scanner scan =new Scanner(System.in);
        int n=scan.nextInt();

        ArrayList<Integer> W = new ArrayList<Integer>();

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

        int sum=0;
        for(Integer temp:W){
            sum+=temp;
        }

        int sumk=0;
        int min=Math.abs(sum-2*W.get(0));
        int diffk;

        for(int j=0;j<n-1;j++){
            
            sumk=0;
            for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            }

            diffk=Math.abs(sum-2*sumk);

            if( diffk < min) min=diffk;

        }
        System.out.print(min);
        
  



    }
} Main
import java.io.*;
import java.util.*;

public class Main{
    
    public static void main(String[] arg){
        Scanner scan =new Scanner(System.in);
        int n=scan.nextInt();

        ArrayList<Integer> W = new ArrayList<Integer>();

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

        int sum=0;
        for(Integer temp:W){
            sum+=temp;
        }

        int sumk=0;
        int min=Math.abs(sum-2*W.get(0));
        int diffk;

        for(int j=0;j<n-1;j++){
            
            sumk=0;
            for(int k=0;k<=j;k++){
                sumk+=W.get(k);
            }

            diffk=Math.abs(sum-2*sumk);

            if( diffk < min) min=diffk;

        }
        System.out.print(min);
        
  



    }
}