import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] arrayv=new int[n];
		int sum1=0,sum2=0,min=99999;

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

		for(int i=1;i<=n;i++) {
			for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			}
			for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			}
			min=Math.min(Math.abs(sum2-sum1), min);
			sum1=0;
			sum2=0;
		}
		System.out.println(min);

	}
}
/*
 6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
 */

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));

 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[] arrayv=new int[n];
		int sum1=0,sum2=0,min=99999;

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

		for(int i=1;i<=n;i++) {
			for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			}
			for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			}
			min=Math.min(Math.abs(sum2-sum1), min);
			sum1=0;
			sum2=0;
		}
		System.out.println(min);

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] arrayv=new int[n];
		int sum1=0,sum2=0,min=99999;

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

		for(int i=1;i<=n;i++) {
			for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			}
			for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			}
			min=Math.min(Math.abs(sum2-sum1), min);
			sum1=0;
			sum2=0;
		}
		System.out.println(min);

	} main {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] arrayv=new int[n];
		int sum1=0,sum2=0,min=99999;

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

		for(int i=1;i<=n;i++) {
			for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			}
			for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			}
			min=Math.min(Math.abs(sum2-sum1), min);
			sum1=0;
			sum2=0;
		}
		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[] arrayv=new int[n]; arrayv new int[n] n int sum1=0 sum1 0 sum2=0 sum2 0 min=99999; min 99999 for(int i=0;i<n;i++) {
			arrayv[i]=sc.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			arrayv[i]=sc.nextInt();
		} {
			arrayv[i]=sc.nextInt();
		} arrayv[i]=sc.nextInt() arrayv[i] arrayv i sc.nextInt() sc.nextInt sc for(int i=1;i<=n;i++) {
			for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			}
			for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			}
			min=Math.min(Math.abs(sum2-sum1), min);
			sum1=0;
			sum2=0;
		} int i=1; int i=1; i 1 i<=n i n i++ i++ i {
			for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			}
			for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			}
			min=Math.min(Math.abs(sum2-sum1), min);
			sum1=0;
			sum2=0;
		} {
			for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			}
			for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			}
			min=Math.min(Math.abs(sum2-sum1), min);
			sum1=0;
			sum2=0;
		} for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			} int j=0; int j=0; j 0 j<i j i j++ j++ j {
				sum1+=arrayv[j];
			} {
				sum1+=arrayv[j];
			} sum1+=arrayv[j] sum1 arrayv[j] arrayv j for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			} int j=i; int j=i; j i j<n j n j++ j++ j {
				sum2+=arrayv[j];
			} {
				sum2+=arrayv[j];
			} sum2+=arrayv[j] sum2 arrayv[j] arrayv j min=Math.min(Math.abs(sum2-sum1), min) min Math.min(Math.abs(sum2-sum1), min) Math.min Math Math.abs(sum2-sum1) Math.abs Math sum2-sum1 sum2 sum1 min sum1=0 sum1 0 sum2=0 sum2 0 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[] arrayv=new int[n];
		int sum1=0,sum2=0,min=99999;

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

		for(int i=1;i<=n;i++) {
			for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			}
			for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			}
			min=Math.min(Math.abs(sum2-sum1), min);
			sum1=0;
			sum2=0;
		}
		System.out.println(min);

	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] arrayv=new int[n];
		int sum1=0,sum2=0,min=99999;

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

		for(int i=1;i<=n;i++) {
			for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			}
			for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			}
			min=Math.min(Math.abs(sum2-sum1), min);
			sum1=0;
			sum2=0;
		}
		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[] arrayv=new int[n];
		int sum1=0,sum2=0,min=99999;

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

		for(int i=1;i<=n;i++) {
			for(int j=0;j<i;j++) {
				sum1+=arrayv[j];
			}
			for(int j=i;j<n;j++) {
				sum2+=arrayv[j];
			}
			min=Math.min(Math.abs(sum2-sum1), min);
			sum1=0;
			sum2=0;
		}
		System.out.println(min);

	}
}
/*
 6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
 */

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));


