import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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 result = Integer.MAX_VALUE;
		int sum = 0;
		for(int i = 0; i < n; i++){
		    w[i] = sc.nextInt();
		    sum += w[i];
		}
		int temp = 0;
		for(int i = 0; i < n; i++){
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		}
		
		// 出力
		System.out.println(result);
		
	}
} import java.util.*; util.* java import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import java.math.BigInteger; BigInteger java.math 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 result = Integer.MAX_VALUE;
		int sum = 0;
		for(int i = 0; i < n; i++){
		    w[i] = sc.nextInt();
		    sum += w[i];
		}
		int temp = 0;
		for(int i = 0; i < n; i++){
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		}
		
		// 出力
		System.out.println(result);
		
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int w[] = new int[n];
		
		// 計算
		int result = Integer.MAX_VALUE;
		int sum = 0;
		for(int i = 0; i < n; i++){
		    w[i] = sc.nextInt();
		    sum += w[i];
		}
		int temp = 0;
		for(int i = 0; i < n; i++){
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		}
		
		// 出力
		System.out.println(result);
		
	} main {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int w[] = new int[n];
		
		// 計算
		int result = Integer.MAX_VALUE;
		int sum = 0;
		for(int i = 0; i < n; i++){
		    w[i] = sc.nextInt();
		    sum += w[i];
		}
		int temp = 0;
		for(int i = 0; i < n; i++){
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		}
		
		// 出力
		System.out.println(result);
		
	} 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 result = Integer.MAX_VALUE; result Integer.MAX_VALUE Integer Integer.MAX_VALUE int sum = 0; sum 0 for(int i = 0; i < n; i++){
		    w[i] = sc.nextInt();
		    sum += w[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
		    w[i] = sc.nextInt();
		    sum += w[i];
		} {
		    w[i] = sc.nextInt();
		    sum += w[i];
		} w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc sum += w[i] sum w[i] w i int temp = 0; temp 0 for(int i = 0; i < n; i++){
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		} {
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		} temp += w[i] temp w[i] w i result = min(result, abs((sum - temp) - temp)) result min(result, abs((sum - temp) - temp)) min result abs((sum - temp) - temp) abs (sum - temp) - temp (sum - temp) sum temp temp System.out.println(result) System.out.println System.out System System.out result 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 result = Integer.MAX_VALUE;
		int sum = 0;
		for(int i = 0; i < n; i++){
		    w[i] = sc.nextInt();
		    sum += w[i];
		}
		int temp = 0;
		for(int i = 0; i < n; i++){
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		}
		
		// 出力
		System.out.println(result);
		
	}
} 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 result = Integer.MAX_VALUE;
		int sum = 0;
		for(int i = 0; i < n; i++){
		    w[i] = sc.nextInt();
		    sum += w[i];
		}
		int temp = 0;
		for(int i = 0; i < n; i++){
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		}
		
		// 出力
		System.out.println(result);
		
	}
} Main
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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 result = Integer.MAX_VALUE;
		int sum = 0;
		for(int i = 0; i < n; i++){
		    w[i] = sc.nextInt();
		    sum += w[i];
		}
		int temp = 0;
		for(int i = 0; i < n; i++){
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		}
		
		// 出力
		System.out.println(result);
		
	}
}
