import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] w = new int[n];
        for(int i = 0; i < n; i++) w[i] = scan.nextInt();
        int out = 10000;
        for(int i = 0; i < n; i++){
            int s1 = 0;
            int s2 = 0;
            for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            }
            if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2);
        }
        System.out.println(out);
        scan.close();
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] w = new int[n];
        for(int i = 0; i < n; i++) w[i] = scan.nextInt();
        int out = 10000;
        for(int i = 0; i < n; i++){
            int s1 = 0;
            int s2 = 0;
            for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            }
            if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2);
        }
        System.out.println(out);
        scan.close();
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] w = new int[n];
        for(int i = 0; i < n; i++) w[i] = scan.nextInt();
        int out = 10000;
        for(int i = 0; i < n; i++){
            int s1 = 0;
            int s2 = 0;
            for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            }
            if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2);
        }
        System.out.println(out);
        scan.close();
    } main {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] w = new int[n];
        for(int i = 0; i < n; i++) w[i] = scan.nextInt();
        int out = 10000;
        for(int i = 0; i < n; i++){
            int s1 = 0;
            int s2 = 0;
            for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            }
            if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2);
        }
        System.out.println(out);
        scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] w = new int[n]; w new int[n] n for(int i = 0; i < n; i++) w[i] = scan.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i w[i] = scan.nextInt(); w[i] = scan.nextInt() w[i] w i scan.nextInt() scan.nextInt scan int out = 10000; out 10000 for(int i = 0; i < n; i++){
            int s1 = 0;
            int s2 = 0;
            for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            }
            if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int s1 = 0;
            int s2 = 0;
            for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            }
            if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2);
        } {
            int s1 = 0;
            int s2 = 0;
            for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            }
            if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2);
        } int s1 = 0; s1 0 int s2 = 0; s2 0 for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            } {
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            } if(j <= i) s1 += w[j];
                else s2 += w[j]; j <= i j i s1 += w[j] s1 w[j] w j s2 += w[j] s2 w[j] w j if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2); out > Math.abs(s1 - s2) out Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 out = Math.abs(s1 - s2) out Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 System.out.println(out) System.out.println System.out System System.out out scan.close() scan.close scan String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] w = new int[n];
        for(int i = 0; i < n; i++) w[i] = scan.nextInt();
        int out = 10000;
        for(int i = 0; i < n; i++){
            int s1 = 0;
            int s2 = 0;
            for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            }
            if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2);
        }
        System.out.println(out);
        scan.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] w = new int[n];
        for(int i = 0; i < n; i++) w[i] = scan.nextInt();
        int out = 10000;
        for(int i = 0; i < n; i++){
            int s1 = 0;
            int s2 = 0;
            for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            }
            if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2);
        }
        System.out.println(out);
        scan.close();
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] w = new int[n];
        for(int i = 0; i < n; i++) w[i] = scan.nextInt();
        int out = 10000;
        for(int i = 0; i < n; i++){
            int s1 = 0;
            int s2 = 0;
            for(int j = 0; j < n; j++){
                if(j <= i) s1 += w[j];
                else s2 += w[j];
            }
            if(out > Math.abs(s1 - s2)) out = Math.abs(s1 - s2);
        }
        System.out.println(out);
        scan.close();
    }
}
