import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] d = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		}
		int diff = sum;
		int s1 = 0;
		for (int i = 0; i < n; i++) {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		}
		System.out.println(diff);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] d = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		}
		int diff = sum;
		int s1 = 0;
		for (int i = 0; i < n; i++) {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		}
		System.out.println(diff);
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] d = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		}
		int diff = sum;
		int s1 = 0;
		for (int i = 0; i < n; i++) {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		}
		System.out.println(diff);
	} main {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] d = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		}
		int diff = sum;
		int s1 = 0;
		for (int i = 0; i < n; i++) {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		}
		System.out.println(diff);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int[] d = new int[n]; d new int[n] n int sum = 0; sum 0 for (int i = 0; i < n; i++) {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		} {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		} d[i] = scanner.nextInt() d[i] d i scanner.nextInt() scanner.nextInt scanner sum = sum + d[i] sum sum + d[i] sum d[i] d i int diff = sum; diff sum int s1 = 0; s1 0 for (int i = 0; i < n; i++) {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		} {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		} s1 = s1 + d[i] s1 s1 + d[i] s1 d[i] d i int sabun = Math.abs((sum - s1) - s1); sabun Math.abs((sum - s1) - s1) Math.abs Math (sum - s1) - s1 (sum - s1) sum s1 s1 if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			} diff < sabun diff sabun {
				break;
			} break; {
				diff = sabun;
			} diff = sabun diff sabun System.out.println(diff) System.out.println System.out System System.out diff String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] d = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		}
		int diff = sum;
		int s1 = 0;
		for (int i = 0; i < n; i++) {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		}
		System.out.println(diff);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] d = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		}
		int diff = sum;
		int s1 = 0;
		for (int i = 0; i < n; i++) {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		}
		System.out.println(diff);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] d = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		}
		int diff = sum;
		int s1 = 0;
		for (int i = 0; i < n; i++) {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		}
		System.out.println(diff);
	}
}
