import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int []array=new int[n];
		int goukei_a=0,goukei_b=0;
		for (int i = 0; i < n; i++) {
			array[i]=scan.nextInt();
			goukei_a+=array[i];
		}
		for(int i=0;i<n;i++){
			goukei_b+=array[i];
			goukei_a-=array[i];
			array[i]=goukei_a-goukei_b;
			if(array[i]<0){
				array[i]=-1*array[i];
			}

		}
		Arrays.sort(array);
		System.out.println(array[0]);

	}

} import java.util.Arrays; Arrays java.util 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 []array=new int[n];
		int goukei_a=0,goukei_b=0;
		for (int i = 0; i < n; i++) {
			array[i]=scan.nextInt();
			goukei_a+=array[i];
		}
		for(int i=0;i<n;i++){
			goukei_b+=array[i];
			goukei_a-=array[i];
			array[i]=goukei_a-goukei_b;
			if(array[i]<0){
				array[i]=-1*array[i];
			}

		}
		Arrays.sort(array);
		System.out.println(array[0]);

	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int []array=new int[n];
		int goukei_a=0,goukei_b=0;
		for (int i = 0; i < n; i++) {
			array[i]=scan.nextInt();
			goukei_a+=array[i];
		}
		for(int i=0;i<n;i++){
			goukei_b+=array[i];
			goukei_a-=array[i];
			array[i]=goukei_a-goukei_b;
			if(array[i]<0){
				array[i]=-1*array[i];
			}

		}
		Arrays.sort(array);
		System.out.println(array[0]);

	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int []array=new int[n];
		int goukei_a=0,goukei_b=0;
		for (int i = 0; i < n; i++) {
			array[i]=scan.nextInt();
			goukei_a+=array[i];
		}
		for(int i=0;i<n;i++){
			goukei_b+=array[i];
			goukei_a-=array[i];
			array[i]=goukei_a-goukei_b;
			if(array[i]<0){
				array[i]=-1*array[i];
			}

		}
		Arrays.sort(array);
		System.out.println(array[0]);

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int []array=new int[n]; array new int[n] n int goukei_a=0 goukei_a 0 goukei_b=0; goukei_b 0 for (int i = 0; i < n; i++) {
			array[i]=scan.nextInt();
			goukei_a+=array[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			array[i]=scan.nextInt();
			goukei_a+=array[i];
		} {
			array[i]=scan.nextInt();
			goukei_a+=array[i];
		} array[i]=scan.nextInt() array[i] array i scan.nextInt() scan.nextInt scan goukei_a+=array[i] goukei_a array[i] array i for(int i=0;i<n;i++){
			goukei_b+=array[i];
			goukei_a-=array[i];
			array[i]=goukei_a-goukei_b;
			if(array[i]<0){
				array[i]=-1*array[i];
			}

		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			goukei_b+=array[i];
			goukei_a-=array[i];
			array[i]=goukei_a-goukei_b;
			if(array[i]<0){
				array[i]=-1*array[i];
			}

		} {
			goukei_b+=array[i];
			goukei_a-=array[i];
			array[i]=goukei_a-goukei_b;
			if(array[i]<0){
				array[i]=-1*array[i];
			}

		} goukei_b+=array[i] goukei_b array[i] array i goukei_a-=array[i] goukei_a array[i] array i array[i]=goukei_a-goukei_b array[i] array i goukei_a-goukei_b goukei_a goukei_b if(array[i]<0){
				array[i]=-1*array[i];
			} array[i]<0 array[i] array i 0 {
				array[i]=-1*array[i];
			} array[i]=-1*array[i] array[i] array i -1*array[i] -1 1 array[i] array i Arrays.sort(array) Arrays.sort Arrays array System.out.println(array[0]) System.out.println System.out System System.out array[0] array 0 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int []array=new int[n];
		int goukei_a=0,goukei_b=0;
		for (int i = 0; i < n; i++) {
			array[i]=scan.nextInt();
			goukei_a+=array[i];
		}
		for(int i=0;i<n;i++){
			goukei_b+=array[i];
			goukei_a-=array[i];
			array[i]=goukei_a-goukei_b;
			if(array[i]<0){
				array[i]=-1*array[i];
			}

		}
		Arrays.sort(array);
		System.out.println(array[0]);

	}

} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int []array=new int[n];
		int goukei_a=0,goukei_b=0;
		for (int i = 0; i < n; i++) {
			array[i]=scan.nextInt();
			goukei_a+=array[i];
		}
		for(int i=0;i<n;i++){
			goukei_b+=array[i];
			goukei_a-=array[i];
			array[i]=goukei_a-goukei_b;
			if(array[i]<0){
				array[i]=-1*array[i];
			}

		}
		Arrays.sort(array);
		System.out.println(array[0]);

	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int []array=new int[n];
		int goukei_a=0,goukei_b=0;
		for (int i = 0; i < n; i++) {
			array[i]=scan.nextInt();
			goukei_a+=array[i];
		}
		for(int i=0;i<n;i++){
			goukei_b+=array[i];
			goukei_a-=array[i];
			array[i]=goukei_a-goukei_b;
			if(array[i]<0){
				array[i]=-1*array[i];
			}

		}
		Arrays.sort(array);
		System.out.println(array[0]);

	}

}