import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[] weight =new int[N];
		int min =Integer.MAX_VALUE;

		for(int i=0;i<N;i++) {
			weight[i]=sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		}
		System.out.println(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[] weight =new int[N];
		int min =Integer.MAX_VALUE;

		for(int i=0;i<N;i++) {
			weight[i]=sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		}
		System.out.println(min);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[] weight =new int[N];
		int min =Integer.MAX_VALUE;

		for(int i=0;i<N;i++) {
			weight[i]=sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[] weight =new int[N];
		int min =Integer.MAX_VALUE;

		for(int i=0;i<N;i++) {
			weight[i]=sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		}
		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[] weight =new int[N]; weight new int[N] N int min =Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i=0;i<N;i++) {
			weight[i]=sc.nextInt();
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			weight[i]=sc.nextInt();
		} {
			weight[i]=sc.nextInt();
		} weight[i]=sc.nextInt() weight[i] weight i sc.nextInt() sc.nextInt sc for(int i=0;i<N;i++) {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		} {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		} int sum1=0; sum1 0 int sum2=0; sum2 0 for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			} int j=0; int j=0; j 0 j<=i j i j++ j++ j {
				sum1+=weight[j];
			} {
				sum1+=weight[j];
			} sum1+=weight[j] sum1 weight[j] weight j for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			} int k=i+1; int k=i+1; k i+1 i 1 k<N k N k++ k++ k {
				sum2+=weight[k];
			} {
				sum2+=weight[k];
			} sum2+=weight[k] sum2 weight[k] weight k int dif = Math.abs(sum1-sum2); dif Math.abs(sum1-sum2) Math.abs Math sum1-sum2 sum1 sum2 if(dif<min) {
				min=dif;
			} dif<min dif min {
				min=dif;
			} min=dif min dif 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[] weight =new int[N];
		int min =Integer.MAX_VALUE;

		for(int i=0;i<N;i++) {
			weight[i]=sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		}
		System.out.println(min);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[] weight =new int[N];
		int min =Integer.MAX_VALUE;

		for(int i=0;i<N;i++) {
			weight[i]=sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		}
		System.out.println(min);
	}
} 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[] weight =new int[N];
		int min =Integer.MAX_VALUE;

		for(int i=0;i<N;i++) {
			weight[i]=sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		}
		System.out.println(min);
	}
}