import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int sum=0;
		int t[]=new int[n];

		for(int i=0;i<n;++i){
			sum=sum+sc.nextInt();
			t[i]=sum;
		}
		int ans=sum;
		for(int i=0;i<n;++i){
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		}

		System.out.println(ans);
	}
} 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 sum=0;
		int t[]=new int[n];

		for(int i=0;i<n;++i){
			sum=sum+sc.nextInt();
			t[i]=sum;
		}
		int ans=sum;
		for(int i=0;i<n;++i){
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		}

		System.out.println(ans);
	}
} Main public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int sum=0;
		int t[]=new int[n];

		for(int i=0;i<n;++i){
			sum=sum+sc.nextInt();
			t[i]=sum;
		}
		int ans=sum;
		for(int i=0;i<n;++i){
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		}

		System.out.println(ans);
	} main {

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int sum=0;
		int t[]=new int[n];

		for(int i=0;i<n;++i){
			sum=sum+sc.nextInt();
			t[i]=sum;
		}
		int ans=sum;
		for(int i=0;i<n;++i){
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		}

		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int sum=0; sum 0 int t[]=new int[n]; t new int[n] n for(int i=0;i<n;++i){
			sum=sum+sc.nextInt();
			t[i]=sum;
		} int i=0; int i=0; i 0 i<n i n ++i ++i i {
			sum=sum+sc.nextInt();
			t[i]=sum;
		} {
			sum=sum+sc.nextInt();
			t[i]=sum;
		} sum=sum+sc.nextInt() sum sum+sc.nextInt() sum sc.nextInt() sc.nextInt sc t[i]=sum t[i] t i sum int ans=sum; ans sum for(int i=0;i<n;++i){
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		} int i=0; int i=0; i 0 i<n i n ++i ++i i {
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		} {
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		} int a=Math.abs(sum-2*t[i]); a Math.abs(sum-2*t[i]) Math.abs Math sum-2*t[i] sum 2*t[i] 2 t[i] t i if(ans>a) ans=a; ans>a ans a ans=a ans a System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int sum=0;
		int t[]=new int[n];

		for(int i=0;i<n;++i){
			sum=sum+sc.nextInt();
			t[i]=sum;
		}
		int ans=sum;
		for(int i=0;i<n;++i){
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		}

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

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int sum=0;
		int t[]=new int[n];

		for(int i=0;i<n;++i){
			sum=sum+sc.nextInt();
			t[i]=sum;
		}
		int ans=sum;
		for(int i=0;i<n;++i){
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		}

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


public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int sum=0;
		int t[]=new int[n];

		for(int i=0;i<n;++i){
			sum=sum+sc.nextInt();
			t[i]=sum;
		}
		int ans=sum;
		for(int i=0;i<n;++i){
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		}

		System.out.println(ans);
	}
}