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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W[] = new int[N+1];
        int T = 0,S1 = 0,S2 = 0,abs = 0,min = 100;

        for(int i = 1; i <= N; i++){
            W[i] = sc.nextInt();
        }

        for (int i = 1; i <= N; i++){
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        }


        System.out.println(min);
        

    }
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W[] = new int[N+1];
        int T = 0,S1 = 0,S2 = 0,abs = 0,min = 100;

        for(int i = 1; i <= N; i++){
            W[i] = sc.nextInt();
        }

        for (int i = 1; i <= N; i++){
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        }


        System.out.println(min);
        

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W[] = new int[N+1];
        int T = 0,S1 = 0,S2 = 0,abs = 0,min = 100;

        for(int i = 1; i <= N; i++){
            W[i] = sc.nextInt();
        }

        for (int i = 1; i <= N; i++){
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        }


        System.out.println(min);
        

    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W[] = new int[N+1];
        int T = 0,S1 = 0,S2 = 0,abs = 0,min = 100;

        for(int i = 1; i <= N; i++){
            W[i] = sc.nextInt();
        }

        for (int i = 1; i <= N; i++){
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        }


        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+1]; W new int[N+1] N+1 N 1 int T = 0 T 0 S1 = 0 S1 0 S2 = 0 S2 0 abs = 0 abs 0 min = 100; min 100 for(int i = 1; i <= N; i++){
            W[i] = sc.nextInt();
        } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
            W[i] = sc.nextInt();
        } {
            W[i] = sc.nextInt();
        } W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc for (int i = 1; i <= N; i++){
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        } {
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        } T = W[i] T W[i] W i for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            } int j = 1; int j = 1; j 1 j <= i j i j++ j++ j {
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            } {
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            } S1 += W[j] S1 W[j] W j for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            } int k = i+1; int k = i+1; k i+1 i 1 k < N+1 k N+1 N 1 k++ k++ k {
                if(N == i){
                    break;
                }
                S2 += W[k];
            } {
                if(N == i){
                    break;
                }
                S2 += W[k];
            } if(N == i){
                    break;
                } N == i N i {
                    break;
                } break; S2 += W[k] S2 W[k] W k abs = S1-S2 abs S1-S2 S1 S2 if(abs < 0){
                abs = -1*abs;
            } abs < 0 abs 0 {
                abs = -1*abs;
            } abs = -1*abs abs -1*abs -1 1 abs if(abs < min){
                min = abs;
            } abs < min abs min {
                min = abs;
            } min = abs min abs S1=0 S1 0 S2=0 S2 0 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) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W[] = new int[N+1];
        int T = 0,S1 = 0,S2 = 0,abs = 0,min = 100;

        for(int i = 1; i <= N; i++){
            W[i] = sc.nextInt();
        }

        for (int i = 1; i <= N; i++){
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        }


        System.out.println(min);
        

    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W[] = new int[N+1];
        int T = 0,S1 = 0,S2 = 0,abs = 0,min = 100;

        for(int i = 1; i <= N; i++){
            W[i] = sc.nextInt();
        }

        for (int i = 1; i <= N; i++){
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        }


        System.out.println(min);
        

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W[] = new int[N+1];
        int T = 0,S1 = 0,S2 = 0,abs = 0,min = 100;

        for(int i = 1; i <= N; i++){
            W[i] = sc.nextInt();
        }

        for (int i = 1; i <= N; i++){
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        }


        System.out.println(min);
        

    }
}
