import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w[] = new int[n];
		for(int i=0; i<n; i++) {
			w[i] = sc.nextInt();
		}
		int min = 1000000000;
		for(int i=0; i<n; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0; j<=i; j++) {
				s1 += w[j];
			}
			for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			}
			int minTemp = Math.abs(s1 - s2);
			if(minTemp < min) {
				min = minTemp;
			}
		}

		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 w[] = new int[n];
		for(int i=0; i<n; i++) {
			w[i] = sc.nextInt();
		}
		int min = 1000000000;
		for(int i=0; i<n; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0; j<=i; j++) {
				s1 += w[j];
			}
			for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			}
			int minTemp = Math.abs(s1 - s2);
			if(minTemp < min) {
				min = minTemp;
			}
		}

		System.out.println(min);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w[] = new int[n];
		for(int i=0; i<n; i++) {
			w[i] = sc.nextInt();
		}
		int min = 1000000000;
		for(int i=0; i<n; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0; j<=i; j++) {
				s1 += w[j];
			}
			for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			}
			int minTemp = Math.abs(s1 - s2);
			if(minTemp < min) {
				min = minTemp;
			}
		}

		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w[] = new int[n];
		for(int i=0; i<n; i++) {
			w[i] = sc.nextInt();
		}
		int min = 1000000000;
		for(int i=0; i<n; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0; j<=i; j++) {
				s1 += w[j];
			}
			for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			}
			int minTemp = Math.abs(s1 - s2);
			if(minTemp < min) {
				min = minTemp;
			}
		}

		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 w[] = new int[n]; w new int[n] n for(int i=0; i<n; i++) {
			w[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			w[i] = sc.nextInt();
		} {
			w[i] = sc.nextInt();
		} w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc int min = 1000000000; min 1000000000 for(int i=0; i<n; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0; j<=i; j++) {
				s1 += w[j];
			}
			for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			}
			int minTemp = Math.abs(s1 - s2);
			if(minTemp < min) {
				min = minTemp;
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0; j<=i; j++) {
				s1 += w[j];
			}
			for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			}
			int minTemp = Math.abs(s1 - s2);
			if(minTemp < min) {
				min = minTemp;
			}
		} {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0; j<=i; j++) {
				s1 += w[j];
			}
			for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			}
			int minTemp = Math.abs(s1 - s2);
			if(minTemp < min) {
				min = minTemp;
			}
		} int s1 = 0; s1 0 int s2 = 0; s2 0 for(int j = 0; j<=i; j++) {
				s1 += w[j];
			} int j = 0; int j = 0; j 0 j<=i j i j++ j++ j {
				s1 += w[j];
			} {
				s1 += w[j];
			} s1 += w[j] s1 w[j] w j for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			} int k = i+1; int k = i+1; k i+1 i 1 k<=n-1 k n-1 n 1 k++ k++ k {
				s2 += w[k];
			} {
				s2 += w[k];
			} s2 += w[k] s2 w[k] w k int minTemp = Math.abs(s1 - s2); minTemp Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 if(minTemp < min) {
				min = minTemp;
			} minTemp < min minTemp min {
				min = minTemp;
			} min = minTemp min minTemp 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 w[] = new int[n];
		for(int i=0; i<n; i++) {
			w[i] = sc.nextInt();
		}
		int min = 1000000000;
		for(int i=0; i<n; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0; j<=i; j++) {
				s1 += w[j];
			}
			for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			}
			int minTemp = Math.abs(s1 - s2);
			if(minTemp < min) {
				min = minTemp;
			}
		}

		System.out.println(min);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w[] = new int[n];
		for(int i=0; i<n; i++) {
			w[i] = sc.nextInt();
		}
		int min = 1000000000;
		for(int i=0; i<n; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0; j<=i; j++) {
				s1 += w[j];
			}
			for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			}
			int minTemp = Math.abs(s1 - s2);
			if(minTemp < min) {
				min = minTemp;
			}
		}

		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 w[] = new int[n];
		for(int i=0; i<n; i++) {
			w[i] = sc.nextInt();
		}
		int min = 1000000000;
		for(int i=0; i<n; i++) {
			int s1 = 0;
			int s2 = 0;
			for(int j = 0; j<=i; j++) {
				s1 += w[j];
			}
			for(int k = i+1; k<=n-1; k++) {
				s2 += w[k];
			}
			int minTemp = Math.abs(s1 - s2);
			if(minTemp < min) {
				min = minTemp;
			}
		}

		System.out.println(min);
	}
}