import static java.lang.Integer.min;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int w[] = new int[N];
        int difference[] = new int[N];
        for(int i = 0; i < w.length; i++){
            w[i] = sc.nextInt();
        }
        int point = 0;
        
        while(point < N){
            int front = 0;
            int back = 0;
            for(int i = 0; i < point; i++){
                front += w[i];
            }
            for(int i = point; i < N; i++){
                back += w[i];
            }
            difference[point] = Math.abs(front - back);
            point++;
        }
        
        int min = difference[0];
        for(int i = 1; i < difference.length; i++){
            min = min(min,difference[i]);
        }
        
        
        System.out.println(min);
        
    }
} import static java.lang.Integer.min; import static java.lang.Integer.min; import static java.lang.Integer.min; import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int w[] = new int[N];
        int difference[] = new int[N];
        for(int i = 0; i < w.length; i++){
            w[i] = sc.nextInt();
        }
        int point = 0;
        
        while(point < N){
            int front = 0;
            int back = 0;
            for(int i = 0; i < point; i++){
                front += w[i];
            }
            for(int i = point; i < N; i++){
                back += w[i];
            }
            difference[point] = Math.abs(front - back);
            point++;
        }
        
        int min = difference[0];
        for(int i = 1; i < difference.length; i++){
            min = min(min,difference[i]);
        }
        
        
        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];
        int difference[] = new int[N];
        for(int i = 0; i < w.length; i++){
            w[i] = sc.nextInt();
        }
        int point = 0;
        
        while(point < N){
            int front = 0;
            int back = 0;
            for(int i = 0; i < point; i++){
                front += w[i];
            }
            for(int i = point; i < N; i++){
                back += w[i];
            }
            difference[point] = Math.abs(front - back);
            point++;
        }
        
        int min = difference[0];
        for(int i = 1; i < difference.length; i++){
            min = min(min,difference[i]);
        }
        
        
        System.out.println(min);
        
    } main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int w[] = new int[N];
        int difference[] = new int[N];
        for(int i = 0; i < w.length; i++){
            w[i] = sc.nextInt();
        }
        int point = 0;
        
        while(point < N){
            int front = 0;
            int back = 0;
            for(int i = 0; i < point; i++){
                front += w[i];
            }
            for(int i = point; i < N; i++){
                back += w[i];
            }
            difference[point] = Math.abs(front - back);
            point++;
        }
        
        int min = difference[0];
        for(int i = 1; i < difference.length; i++){
            min = min(min,difference[i]);
        }
        
        
        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 difference[] = new int[N]; difference new int[N] N for(int i = 0; i < w.length; i++){
            w[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < w.length i w.length w w.length i++ i++ i {
            w[i] = sc.nextInt();
        } {
            w[i] = sc.nextInt();
        } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc int point = 0; point 0 while(point < N){
            int front = 0;
            int back = 0;
            for(int i = 0; i < point; i++){
                front += w[i];
            }
            for(int i = point; i < N; i++){
                back += w[i];
            }
            difference[point] = Math.abs(front - back);
            point++;
        } point < N point N {
            int front = 0;
            int back = 0;
            for(int i = 0; i < point; i++){
                front += w[i];
            }
            for(int i = point; i < N; i++){
                back += w[i];
            }
            difference[point] = Math.abs(front - back);
            point++;
        } int front = 0; front 0 int back = 0; back 0 for(int i = 0; i < point; i++){
                front += w[i];
            } int i = 0; int i = 0; i 0 i < point i point i++ i++ i {
                front += w[i];
            } {
                front += w[i];
            } front += w[i] front w[i] w i for(int i = point; i < N; i++){
                back += w[i];
            } int i = point; int i = point; i point i < N i N i++ i++ i {
                back += w[i];
            } {
                back += w[i];
            } back += w[i] back w[i] w i difference[point] = Math.abs(front - back) difference[point] difference point Math.abs(front - back) Math.abs Math front - back front back point++ point int min = difference[0]; min difference[0] difference 0 for(int i = 1; i < difference.length; i++){
            min = min(min,difference[i]);
        } int i = 1; int i = 1; i 1 i < difference.length i difference.length difference difference.length i++ i++ i {
            min = min(min,difference[i]);
        } {
            min = min(min,difference[i]);
        } min = min(min,difference[i]) min min(min,difference[i]) min min difference[i] difference i 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];
        int difference[] = new int[N];
        for(int i = 0; i < w.length; i++){
            w[i] = sc.nextInt();
        }
        int point = 0;
        
        while(point < N){
            int front = 0;
            int back = 0;
            for(int i = 0; i < point; i++){
                front += w[i];
            }
            for(int i = point; i < N; i++){
                back += w[i];
            }
            difference[point] = Math.abs(front - back);
            point++;
        }
        
        int min = difference[0];
        for(int i = 1; i < difference.length; i++){
            min = min(min,difference[i]);
        }
        
        
        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];
        int difference[] = new int[N];
        for(int i = 0; i < w.length; i++){
            w[i] = sc.nextInt();
        }
        int point = 0;
        
        while(point < N){
            int front = 0;
            int back = 0;
            for(int i = 0; i < point; i++){
                front += w[i];
            }
            for(int i = point; i < N; i++){
                back += w[i];
            }
            difference[point] = Math.abs(front - back);
            point++;
        }
        
        int min = difference[0];
        for(int i = 1; i < difference.length; i++){
            min = min(min,difference[i]);
        }
        
        
        System.out.println(min);
        
    }
} Main
import static java.lang.Integer.min;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int w[] = new int[N];
        int difference[] = new int[N];
        for(int i = 0; i < w.length; i++){
            w[i] = sc.nextInt();
        }
        int point = 0;
        
        while(point < N){
            int front = 0;
            int back = 0;
            for(int i = 0; i < point; i++){
                front += w[i];
            }
            for(int i = point; i < N; i++){
                back += w[i];
            }
            difference[point] = Math.abs(front - back);
            point++;
        }
        
        int min = difference[0];
        for(int i = 1; i < difference.length; i++){
            min = min(min,difference[i]);
        }
        
        
        System.out.println(min);
        
    }
}
