import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
      	for (int i = 0; i<n; i++){
          a[i] = sc.nextInt();
        }
		int min = 10000;
      	int f = 0;
      	int l = 0;
      	int i = 0;
		for(int j = 0; j < n; j++){
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 0;
        }
		System.out.println(min);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
      	for (int i = 0; i<n; i++){
          a[i] = sc.nextInt();
        }
		int min = 10000;
      	int f = 0;
      	int l = 0;
      	int i = 0;
		for(int j = 0; j < n; j++){
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 0;
        }
		System.out.println(min);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
      	for (int i = 0; i<n; i++){
          a[i] = sc.nextInt();
        }
		int min = 10000;
      	int f = 0;
      	int l = 0;
      	int i = 0;
		for(int j = 0; j < n; j++){
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 0;
        }
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
      	for (int i = 0; i<n; i++){
          a[i] = sc.nextInt();
        }
		int min = 10000;
      	int f = 0;
      	int l = 0;
      	int i = 0;
		for(int j = 0; j < n; j++){
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 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 a[] = new int[n]; a new int[n] n for (int i = 0; i<n; i++){
          a[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
          a[i] = sc.nextInt();
        } {
          a[i] = sc.nextInt();
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc int min = 10000; min 10000 int f = 0; f 0 int l = 0; l 0 int i = 0; i 0 for(int j = 0; j < n; j++){
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 0;
        } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 0;
        } {
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 0;
        } for (int k = 0; k<j; k++){
            f += a[k];
          } int k = 0; int k = 0; k 0 k<j k j k++ k++ k {
            f += a[k];
          } {
            f += a[k];
          } f += a[k] f a[k] a k for (int m = j; m<n; m++){
            l += a[m];
          } int m = j; int m = j; m j m<n m n m++ m++ m {
            l += a[m];
          } {
            l += a[m];
          } l += a[m] l a[m] a m if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          } min > Math.abs(f-l) min Math.abs(f-l) Math.abs Math f-l f l {
            min = Math.abs(f-l);
          } min = Math.abs(f-l) min Math.abs(f-l) Math.abs Math f-l f l f = 0 f 0 l = 0 l 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 a[] = new int[n];
      	for (int i = 0; i<n; i++){
          a[i] = sc.nextInt();
        }
		int min = 10000;
      	int f = 0;
      	int l = 0;
      	int i = 0;
		for(int j = 0; j < n; j++){
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 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 a[] = new int[n];
      	for (int i = 0; i<n; i++){
          a[i] = sc.nextInt();
        }
		int min = 10000;
      	int f = 0;
      	int l = 0;
      	int i = 0;
		for(int j = 0; j < n; j++){
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 0;
        }
		System.out.println(min);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
      	for (int i = 0; i<n; i++){
          a[i] = sc.nextInt();
        }
		int min = 10000;
      	int f = 0;
      	int l = 0;
      	int i = 0;
		for(int j = 0; j < n; j++){
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 0;
        }
		System.out.println(min);
	}
}