import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int w[]=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			w[i]=scan.nextInt();
			sum+=w[i];
		}
		scan.close();
		int sum2=0;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n;i++) {
			sum2+=w[i];
			if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2);

		}
		System.out.println(min);
	}
} import java.util.Scanner; Scanner 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];
		int sum=0;
		for(int i=0;i<n;i++) {
			w[i]=scan.nextInt();
			sum+=w[i];
		}
		scan.close();
		int sum2=0;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n;i++) {
			sum2+=w[i];
			if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2);

		}
		System.out.println(min);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int w[]=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			w[i]=scan.nextInt();
			sum+=w[i];
		}
		scan.close();
		int sum2=0;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n;i++) {
			sum2+=w[i];
			if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2);

		}
		System.out.println(min);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int w[]=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			w[i]=scan.nextInt();
			sum+=w[i];
		}
		scan.close();
		int sum2=0;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n;i++) {
			sum2+=w[i];
			if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2);

		}
		System.out.println(min);
	} 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 int sum=0; sum 0 for(int i=0;i<n;i++) {
			w[i]=scan.nextInt();
			sum+=w[i];
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			w[i]=scan.nextInt();
			sum+=w[i];
		} {
			w[i]=scan.nextInt();
			sum+=w[i];
		} w[i]=scan.nextInt() w[i] w i scan.nextInt() scan.nextInt scan sum+=w[i] sum w[i] w i scan.close() scan.close scan int sum2=0; sum2 0 int min=Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i=0;i<n;i++) {
			sum2+=w[i];
			if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2);

		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			sum2+=w[i];
			if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2);

		} {
			sum2+=w[i];
			if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2);

		} sum2+=w[i] sum2 w[i] w i if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2); min>Math.abs(sum-sum2*2) min Math.abs(sum-sum2*2) Math.abs Math sum-sum2*2 sum sum2*2 sum2 2 min=Math.abs(sum-sum2*2) min Math.abs(sum-sum2*2) Math.abs Math sum-sum2*2 sum sum2*2 sum2 2 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 scan = new Scanner(System.in);
		int n = scan.nextInt();
		int w[]=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			w[i]=scan.nextInt();
			sum+=w[i];
		}
		scan.close();
		int sum2=0;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n;i++) {
			sum2+=w[i];
			if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2);

		}
		System.out.println(min);
	}
} public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int w[]=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			w[i]=scan.nextInt();
			sum+=w[i];
		}
		scan.close();
		int sum2=0;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n;i++) {
			sum2+=w[i];
			if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2);

		}
		System.out.println(min);
	}
} Main
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int w[]=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			w[i]=scan.nextInt();
			sum+=w[i];
		}
		scan.close();
		int sum2=0;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n;i++) {
			sum2+=w[i];
			if(min>Math.abs(sum-sum2*2))min=Math.abs(sum-sum2*2);

		}
		System.out.println(min);
	}
}