import java.util.Scanner;

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 nowSum = 0;
		int allSum = 0;
		int minSum = Integer.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			allSum += W[i];
		}

		for (int i = 0; i < N; i++) {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		}

		System.out.println(minSum);
	}
} import java.util.Scanner; Scanner 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 nowSum = 0;
		int allSum = 0;
		int minSum = Integer.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			allSum += W[i];
		}

		for (int i = 0; i < N; i++) {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		}

		System.out.println(minSum);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W[] = new int[N];
		int nowSum = 0;
		int allSum = 0;
		int minSum = Integer.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			allSum += W[i];
		}

		for (int i = 0; i < N; i++) {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		}

		System.out.println(minSum);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W[] = new int[N];
		int nowSum = 0;
		int allSum = 0;
		int minSum = Integer.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			allSum += W[i];
		}

		for (int i = 0; i < N; i++) {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		}

		System.out.println(minSum);
	} 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 nowSum = 0; nowSum 0 int allSum = 0; allSum 0 int minSum = Integer.MAX_VALUE; minSum Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			allSum += W[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			W[i] = sc.nextInt();
			allSum += W[i];
		} {
			W[i] = sc.nextInt();
			allSum += W[i];
		} W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc allSum += W[i] allSum W[i] W i for (int i = 0; i < N; i++) {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		} {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		} nowSum += W[i] nowSum W[i] W i minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum))) minSum Math.min(minSum, Math.abs(nowSum - (allSum - nowSum))) Math.min Math minSum Math.abs(nowSum - (allSum - nowSum)) Math.abs Math nowSum - (allSum - nowSum) nowSum (allSum - nowSum) allSum nowSum System.out.println(minSum) System.out.println System.out System System.out minSum 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 nowSum = 0;
		int allSum = 0;
		int minSum = Integer.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			allSum += W[i];
		}

		for (int i = 0; i < N; i++) {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		}

		System.out.println(minSum);
	}
} 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 nowSum = 0;
		int allSum = 0;
		int minSum = Integer.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			allSum += W[i];
		}

		for (int i = 0; i < N; i++) {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		}

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

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 nowSum = 0;
		int allSum = 0;
		int minSum = Integer.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			allSum += W[i];
		}

		for (int i = 0; i < N; i++) {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		}

		System.out.println(minSum);
	}
}
