import 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];
      	int a = 0;
      	int b;
      	//重さの入力
      	for(int i=0;i<n;i++){
          w[i] = sc.nextInt();
        }
		int sum = java.util.Arrays.stream(w).sum();
      	int jud = sum;
      	int dif;
      	for(int i=0;i<n;i++){
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        }
		// 出力
		System.out.println(jud);
	}
} 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[] w = new int[n];
      	int a = 0;
      	int b;
      	//重さの入力
      	for(int i=0;i<n;i++){
          w[i] = sc.nextInt();
        }
		int sum = java.util.Arrays.stream(w).sum();
      	int jud = sum;
      	int dif;
      	for(int i=0;i<n;i++){
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        }
		// 出力
		System.out.println(jud);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 個数の入力
		int n = sc.nextInt();
      	int[] w = new int[n];
      	int a = 0;
      	int b;
      	//重さの入力
      	for(int i=0;i<n;i++){
          w[i] = sc.nextInt();
        }
		int sum = java.util.Arrays.stream(w).sum();
      	int jud = sum;
      	int dif;
      	for(int i=0;i<n;i++){
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        }
		// 出力
		System.out.println(jud);
	} main {
		Scanner sc = new Scanner(System.in);
		// 個数の入力
		int n = sc.nextInt();
      	int[] w = new int[n];
      	int a = 0;
      	int b;
      	//重さの入力
      	for(int i=0;i<n;i++){
          w[i] = sc.nextInt();
        }
		int sum = java.util.Arrays.stream(w).sum();
      	int jud = sum;
      	int dif;
      	for(int i=0;i<n;i++){
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        }
		// 出力
		System.out.println(jud);
	} 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 int a = 0; a 0 int b; b 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 sum = java.util.Arrays.stream(w).sum(); sum java.util.Arrays.stream(w).sum() java.util.Arrays.stream(w).sum java.util.Arrays.stream(w) java.util.Arrays.stream java.util.Arrays java.util java java.util java.util.Arrays w int jud = sum; jud sum int dif; dif for(int i=0;i<n;i++){
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        } {
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        } a = a + w[i] a a + w[i] a w[i] w i b = sum - a b sum - a sum a dif = Math.abs(a-b) dif Math.abs(a-b) Math.abs Math a-b a b if(dif <= jud){
            jud = dif;
          } dif <= jud dif jud {
            jud = dif;
          } jud = dif jud dif System.out.println(jud) System.out.println System.out System System.out jud 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];
      	int a = 0;
      	int b;
      	//重さの入力
      	for(int i=0;i<n;i++){
          w[i] = sc.nextInt();
        }
		int sum = java.util.Arrays.stream(w).sum();
      	int jud = sum;
      	int dif;
      	for(int i=0;i<n;i++){
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        }
		// 出力
		System.out.println(jud);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 個数の入力
		int n = sc.nextInt();
      	int[] w = new int[n];
      	int a = 0;
      	int b;
      	//重さの入力
      	for(int i=0;i<n;i++){
          w[i] = sc.nextInt();
        }
		int sum = java.util.Arrays.stream(w).sum();
      	int jud = sum;
      	int dif;
      	for(int i=0;i<n;i++){
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        }
		// 出力
		System.out.println(jud);
	}
} Main
import 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];
      	int a = 0;
      	int b;
      	//重さの入力
      	for(int i=0;i<n;i++){
          w[i] = sc.nextInt();
        }
		int sum = java.util.Arrays.stream(w).sum();
      	int jud = sum;
      	int dif;
      	for(int i=0;i<n;i++){
          a = a + w[i];
          b = sum - a;
          dif = Math.abs(a-b);
          if(dif <= jud){
            jud = dif;
          }
        }
		// 出力
		System.out.println(jud);
	}
}