import java.util.Scanner;
public class Main {

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

} import java.util.Scanner; Scanner java.util public class Main {

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

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] weight = new int[n];
		
		for(int i = 0; i < n; i++) {
			weight[i] = stdIn.nextInt();
		}
		
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < n-1; i++) {
			int sum1 = 0;
			int sum2 = 0;
			int j = 0;
			for( j = 0; j < i+1; j++) {
				sum1 += weight[j];
				}
			for(int k = j; k < n; k++) {
				sum2 += weight[k];
			}
			ans = Math.min(ans, Math.abs(sum1-sum2));
		}
		
		
		System.out.println(ans);
		
		
	} main {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] weight = new int[n];
		
		for(int i = 0; i < n; i++) {
			weight[i] = stdIn.nextInt();
		}
		
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < n-1; i++) {
			int sum1 = 0;
			int sum2 = 0;
			int j = 0;
			for( j = 0; j < i+1; j++) {
				sum1 += weight[j];
				}
			for(int k = j; k < n; k++) {
				sum2 += weight[k];
			}
			ans = Math.min(ans, Math.abs(sum1-sum2));
		}
		
		
		System.out.println(ans);
		
		
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int[] weight = new int[n]; weight new int[n] n for(int i = 0; i < n; i++) {
			weight[i] = stdIn.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			weight[i] = stdIn.nextInt();
		} {
			weight[i] = stdIn.nextInt();
		} weight[i] = stdIn.nextInt() weight[i] weight i stdIn.nextInt() stdIn.nextInt stdIn int ans = Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 0; i < n-1; i++) {
			int sum1 = 0;
			int sum2 = 0;
			int j = 0;
			for( j = 0; j < i+1; j++) {
				sum1 += weight[j];
				}
			for(int k = j; k < n; k++) {
				sum2 += weight[k];
			}
			ans = Math.min(ans, Math.abs(sum1-sum2));
		} int i = 0; int i = 0; i 0 i < n-1 i n-1 n 1 i++ i++ i {
			int sum1 = 0;
			int sum2 = 0;
			int j = 0;
			for( j = 0; j < i+1; j++) {
				sum1 += weight[j];
				}
			for(int k = j; k < n; k++) {
				sum2 += weight[k];
			}
			ans = Math.min(ans, Math.abs(sum1-sum2));
		} {
			int sum1 = 0;
			int sum2 = 0;
			int j = 0;
			for( j = 0; j < i+1; j++) {
				sum1 += weight[j];
				}
			for(int k = j; k < n; k++) {
				sum2 += weight[k];
			}
			ans = Math.min(ans, Math.abs(sum1-sum2));
		} int sum1 = 0; sum1 0 int sum2 = 0; sum2 0 int j = 0; j 0 for( j = 0; j < i+1; j++) {
				sum1 += weight[j];
				} j = 0; j = 0 j 0 j < i+1 j i+1 i 1 j++ j++ j {
				sum1 += weight[j];
				} {
				sum1 += weight[j];
				} sum1 += weight[j] sum1 weight[j] weight j for(int k = j; k < n; k++) {
				sum2 += weight[k];
			} int k = j; int k = j; k j k < n k n k++ k++ k {
				sum2 += weight[k];
			} {
				sum2 += weight[k];
			} sum2 += weight[k] sum2 weight[k] weight k ans = Math.min(ans, Math.abs(sum1-sum2)) ans Math.min(ans, Math.abs(sum1-sum2)) Math.min Math ans Math.abs(sum1-sum2) Math.abs Math sum1-sum2 sum1 sum2 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 stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] weight = new int[n];
		
		for(int i = 0; i < n; i++) {
			weight[i] = stdIn.nextInt();
		}
		
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < n-1; i++) {
			int sum1 = 0;
			int sum2 = 0;
			int j = 0;
			for( j = 0; j < i+1; j++) {
				sum1 += weight[j];
				}
			for(int k = j; k < n; k++) {
				sum2 += weight[k];
			}
			ans = Math.min(ans, Math.abs(sum1-sum2));
		}
		
		
		System.out.println(ans);
		
		
	}

} public class Main {

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

} Main
import java.util.Scanner;
public class Main {

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

}
