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

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> W = new ArrayList<>();
        for(int i=0; i<N; i++){
            W.add(scanner.nextInt());
        }

        int wLeft = 0;
        int wRight = 0;
        for(int i=0; i<N; i++){
            wRight += W.get(i);
        }
        int minAbsDiff = wRight;
        for(int i=0; i<N; i++){
            int absDiff = Math.abs(wLeft - wRight);
            if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            }
            wLeft += W.get(i);
            wRight -= W.get(i);
        }

        System.out.println(minAbsDiff);
    }
} import java.util.*; util.* java import java.lang.*; lang.* java public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> W = new ArrayList<>();
        for(int i=0; i<N; i++){
            W.add(scanner.nextInt());
        }

        int wLeft = 0;
        int wRight = 0;
        for(int i=0; i<N; i++){
            wRight += W.get(i);
        }
        int minAbsDiff = wRight;
        for(int i=0; i<N; i++){
            int absDiff = Math.abs(wLeft - wRight);
            if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            }
            wLeft += W.get(i);
            wRight -= W.get(i);
        }

        System.out.println(minAbsDiff);
    }
} Main public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> W = new ArrayList<>();
        for(int i=0; i<N; i++){
            W.add(scanner.nextInt());
        }

        int wLeft = 0;
        int wRight = 0;
        for(int i=0; i<N; i++){
            wRight += W.get(i);
        }
        int minAbsDiff = wRight;
        for(int i=0; i<N; i++){
            int absDiff = Math.abs(wLeft - wRight);
            if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            }
            wLeft += W.get(i);
            wRight -= W.get(i);
        }

        System.out.println(minAbsDiff);
    } main {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> W = new ArrayList<>();
        for(int i=0; i<N; i++){
            W.add(scanner.nextInt());
        }

        int wLeft = 0;
        int wRight = 0;
        for(int i=0; i<N; i++){
            wRight += W.get(i);
        }
        int minAbsDiff = wRight;
        for(int i=0; i<N; i++){
            int absDiff = Math.abs(wLeft - wRight);
            if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            }
            wLeft += W.get(i);
            wRight -= W.get(i);
        }

        System.out.println(minAbsDiff);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner List<Integer> W = new ArrayList<>(); W new ArrayList<>() for(int i=0; i<N; i++){
            W.add(scanner.nextInt());
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            W.add(scanner.nextInt());
        } {
            W.add(scanner.nextInt());
        } W.add(scanner.nextInt()) W.add W scanner.nextInt() scanner.nextInt scanner int wLeft = 0; wLeft 0 int wRight = 0; wRight 0 for(int i=0; i<N; i++){
            wRight += W.get(i);
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            wRight += W.get(i);
        } {
            wRight += W.get(i);
        } wRight += W.get(i) wRight W.get(i) W.get W i int minAbsDiff = wRight; minAbsDiff wRight for(int i=0; i<N; i++){
            int absDiff = Math.abs(wLeft - wRight);
            if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            }
            wLeft += W.get(i);
            wRight -= W.get(i);
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            int absDiff = Math.abs(wLeft - wRight);
            if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            }
            wLeft += W.get(i);
            wRight -= W.get(i);
        } {
            int absDiff = Math.abs(wLeft - wRight);
            if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            }
            wLeft += W.get(i);
            wRight -= W.get(i);
        } int absDiff = Math.abs(wLeft - wRight); absDiff Math.abs(wLeft - wRight) Math.abs Math wLeft - wRight wLeft wRight if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            } absDiff < minAbsDiff absDiff minAbsDiff {
                minAbsDiff = absDiff;
            } minAbsDiff = absDiff minAbsDiff absDiff wLeft += W.get(i) wLeft W.get(i) W.get W i wRight -= W.get(i) wRight W.get(i) W.get W i System.out.println(minAbsDiff) System.out.println System.out System System.out minAbsDiff String args[] args public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> W = new ArrayList<>();
        for(int i=0; i<N; i++){
            W.add(scanner.nextInt());
        }

        int wLeft = 0;
        int wRight = 0;
        for(int i=0; i<N; i++){
            wRight += W.get(i);
        }
        int minAbsDiff = wRight;
        for(int i=0; i<N; i++){
            int absDiff = Math.abs(wLeft - wRight);
            if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            }
            wLeft += W.get(i);
            wRight -= W.get(i);
        }

        System.out.println(minAbsDiff);
    }
} public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> W = new ArrayList<>();
        for(int i=0; i<N; i++){
            W.add(scanner.nextInt());
        }

        int wLeft = 0;
        int wRight = 0;
        for(int i=0; i<N; i++){
            wRight += W.get(i);
        }
        int minAbsDiff = wRight;
        for(int i=0; i<N; i++){
            int absDiff = Math.abs(wLeft - wRight);
            if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            }
            wLeft += W.get(i);
            wRight -= W.get(i);
        }

        System.out.println(minAbsDiff);
    }
} Main
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> W = new ArrayList<>();
        for(int i=0; i<N; i++){
            W.add(scanner.nextInt());
        }

        int wLeft = 0;
        int wRight = 0;
        for(int i=0; i<N; i++){
            wRight += W.get(i);
        }
        int minAbsDiff = wRight;
        for(int i=0; i<N; i++){
            int absDiff = Math.abs(wLeft - wRight);
            if(absDiff < minAbsDiff){
                minAbsDiff = absDiff;
            }
            wLeft += W.get(i);
            wRight -= W.get(i);
        }

        System.out.println(minAbsDiff);
    }
}