import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int[] s = new int[n];
		int[] ss = new int[n + 1];
		ss[0] = 0;
		long sum = 0;
		int i;
		for(i = 0; i < n; i++) {
			s[i] = scan.nextInt();
			ss[i + 1] = ss[i] + s[i];
			sum += s[i];
		}

		long min = Long.MAX_VALUE;
		long temp;
		for(i = 0; i < n; i++) {
			temp = sum - ss[i];
			min = Math.min(Math.abs(temp - ss[i]), min);
		}

		System.out.println(min);
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int[] s = new int[n];
		int[] ss = new int[n + 1];
		ss[0] = 0;
		long sum = 0;
		int i;
		for(i = 0; i < n; i++) {
			s[i] = scan.nextInt();
			ss[i + 1] = ss[i] + s[i];
			sum += s[i];
		}

		long min = Long.MAX_VALUE;
		long temp;
		for(i = 0; i < n; i++) {
			temp = sum - ss[i];
			min = Math.min(Math.abs(temp - ss[i]), min);
		}

		System.out.println(min);
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int[] s = new int[n];
		int[] ss = new int[n + 1];
		ss[0] = 0;
		long sum = 0;
		int i;
		for(i = 0; i < n; i++) {
			s[i] = scan.nextInt();
			ss[i + 1] = ss[i] + s[i];
			sum += s[i];
		}

		long min = Long.MAX_VALUE;
		long temp;
		for(i = 0; i < n; i++) {
			temp = sum - ss[i];
			min = Math.min(Math.abs(temp - ss[i]), min);
		}

		System.out.println(min);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int[] s = new int[n];
		int[] ss = new int[n + 1];
		ss[0] = 0;
		long sum = 0;
		int i;
		for(i = 0; i < n; i++) {
			s[i] = scan.nextInt();
			ss[i + 1] = ss[i] + s[i];
			sum += s[i];
		}

		long min = Long.MAX_VALUE;
		long temp;
		for(i = 0; i < n; i++) {
			temp = sum - ss[i];
			min = Math.min(Math.abs(temp - ss[i]), min);
		}

		System.out.println(min);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] s = new int[n]; s new int[n] n int[] ss = new int[n + 1]; ss new int[n + 1] n + 1 n 1 ss[0] = 0 ss[0] ss 0 0 long sum = 0; sum 0 int i; i for(i = 0; i < n; i++) {
			s[i] = scan.nextInt();
			ss[i + 1] = ss[i] + s[i];
			sum += s[i];
		} i = 0; i = 0 i 0 i < n i n i++ i++ i {
			s[i] = scan.nextInt();
			ss[i + 1] = ss[i] + s[i];
			sum += s[i];
		} {
			s[i] = scan.nextInt();
			ss[i + 1] = ss[i] + s[i];
			sum += s[i];
		} s[i] = scan.nextInt() s[i] s i scan.nextInt() scan.nextInt scan ss[i + 1] = ss[i] + s[i] ss[i + 1] ss i + 1 i 1 ss[i] + s[i] ss[i] ss i s[i] s i sum += s[i] sum s[i] s i long min = Long.MAX_VALUE; min Long.MAX_VALUE Long Long.MAX_VALUE long temp; temp for(i = 0; i < n; i++) {
			temp = sum - ss[i];
			min = Math.min(Math.abs(temp - ss[i]), min);
		} i = 0; i = 0 i 0 i < n i n i++ i++ i {
			temp = sum - ss[i];
			min = Math.min(Math.abs(temp - ss[i]), min);
		} {
			temp = sum - ss[i];
			min = Math.min(Math.abs(temp - ss[i]), min);
		} temp = sum - ss[i] temp sum - ss[i] sum ss[i] ss i min = Math.min(Math.abs(temp - ss[i]), min) min Math.min(Math.abs(temp - ss[i]), min) Math.min Math Math.abs(temp - ss[i]) Math.abs Math temp - ss[i] temp ss[i] ss i min 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 scan = new Scanner(System.in);
		int n = scan.nextInt();

		int[] s = new int[n];
		int[] ss = new int[n + 1];
		ss[0] = 0;
		long sum = 0;
		int i;
		for(i = 0; i < n; i++) {
			s[i] = scan.nextInt();
			ss[i + 1] = ss[i] + s[i];
			sum += s[i];
		}

		long min = Long.MAX_VALUE;
		long temp;
		for(i = 0; i < n; i++) {
			temp = sum - ss[i];
			min = Math.min(Math.abs(temp - ss[i]), min);
		}

		System.out.println(min);
	}
} public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int[] s = new int[n];
		int[] ss = new int[n + 1];
		ss[0] = 0;
		long sum = 0;
		int i;
		for(i = 0; i < n; i++) {
			s[i] = scan.nextInt();
			ss[i + 1] = ss[i] + s[i];
			sum += s[i];
		}

		long min = Long.MAX_VALUE;
		long temp;
		for(i = 0; i < n; i++) {
			temp = sum - ss[i];
			min = Math.min(Math.abs(temp - ss[i]), min);
		}

		System.out.println(min);
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int[] s = new int[n];
		int[] ss = new int[n + 1];
		ss[0] = 0;
		long sum = 0;
		int i;
		for(i = 0; i < n; i++) {
			s[i] = scan.nextInt();
			ss[i + 1] = ss[i] + s[i];
			sum += s[i];
		}

		long min = Long.MAX_VALUE;
		long temp;
		for(i = 0; i < n; i++) {
			temp = sum - ss[i];
			min = Math.min(Math.abs(temp - ss[i]), min);
		}

		System.out.println(min);
	}
}
