import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] prefix = new int[n];
		int[] postfix = new int[n];
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++) {
			int w = sc.nextInt();
			nums[i] = w;
		}
		
		prefix[0] = nums[0];
		
		for (int i = 1; i < nums.length; i++) {
			prefix[i] = nums[i] + prefix[i-1];
		}

		postfix[n-1] = nums[n-1];
		
		for (int i = n - 2; i >= 0; i--) {
			postfix[i] = postfix[i+1] + nums[i];
		}

		int res = Integer.MAX_VALUE;
		
		for (int i = 1; i < n; i++) {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		}
		
		System.out.println(res);
	}

} 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[] prefix = new int[n];
		int[] postfix = new int[n];
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++) {
			int w = sc.nextInt();
			nums[i] = w;
		}
		
		prefix[0] = nums[0];
		
		for (int i = 1; i < nums.length; i++) {
			prefix[i] = nums[i] + prefix[i-1];
		}

		postfix[n-1] = nums[n-1];
		
		for (int i = n - 2; i >= 0; i--) {
			postfix[i] = postfix[i+1] + nums[i];
		}

		int res = Integer.MAX_VALUE;
		
		for (int i = 1; i < n; i++) {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		}
		
		System.out.println(res);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] prefix = new int[n];
		int[] postfix = new int[n];
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++) {
			int w = sc.nextInt();
			nums[i] = w;
		}
		
		prefix[0] = nums[0];
		
		for (int i = 1; i < nums.length; i++) {
			prefix[i] = nums[i] + prefix[i-1];
		}

		postfix[n-1] = nums[n-1];
		
		for (int i = n - 2; i >= 0; i--) {
			postfix[i] = postfix[i+1] + nums[i];
		}

		int res = Integer.MAX_VALUE;
		
		for (int i = 1; i < n; i++) {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		}
		
		System.out.println(res);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] prefix = new int[n];
		int[] postfix = new int[n];
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++) {
			int w = sc.nextInt();
			nums[i] = w;
		}
		
		prefix[0] = nums[0];
		
		for (int i = 1; i < nums.length; i++) {
			prefix[i] = nums[i] + prefix[i-1];
		}

		postfix[n-1] = nums[n-1];
		
		for (int i = n - 2; i >= 0; i--) {
			postfix[i] = postfix[i+1] + nums[i];
		}

		int res = Integer.MAX_VALUE;
		
		for (int i = 1; i < n; i++) {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		}
		
		System.out.println(res);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] prefix = new int[n]; prefix new int[n] n int[] postfix = new int[n]; postfix new int[n] n int[] nums = new int[n]; nums new int[n] n for (int i = 0; i < n; i++) {
			int w = sc.nextInt();
			nums[i] = w;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int w = sc.nextInt();
			nums[i] = w;
		} {
			int w = sc.nextInt();
			nums[i] = w;
		} int w = sc.nextInt(); w sc.nextInt() sc.nextInt sc nums[i] = w nums[i] nums i w prefix[0] = nums[0] prefix[0] prefix 0 nums[0] nums 0 for (int i = 1; i < nums.length; i++) {
			prefix[i] = nums[i] + prefix[i-1];
		} int i = 1; int i = 1; i 1 i < nums.length i nums.length nums nums.length i++ i++ i {
			prefix[i] = nums[i] + prefix[i-1];
		} {
			prefix[i] = nums[i] + prefix[i-1];
		} prefix[i] = nums[i] + prefix[i-1] prefix[i] prefix i nums[i] + prefix[i-1] nums[i] nums i prefix[i-1] prefix i-1 i 1 postfix[n-1] = nums[n-1] postfix[n-1] postfix n-1 n 1 nums[n-1] nums n-1 n 1 for (int i = n - 2; i >= 0; i--) {
			postfix[i] = postfix[i+1] + nums[i];
		} int i = n - 2; int i = n - 2; i n - 2 n 2 i >= 0 i 0 i-- i-- i {
			postfix[i] = postfix[i+1] + nums[i];
		} {
			postfix[i] = postfix[i+1] + nums[i];
		} postfix[i] = postfix[i+1] + nums[i] postfix[i] postfix i postfix[i+1] + nums[i] postfix[i+1] postfix i+1 i 1 nums[i] nums i int res = Integer.MAX_VALUE; res Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 1; i < n; i++) {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		} {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		} res = Math.min(res, Math.abs(postfix[i] - prefix[i-1])) res Math.min(res, Math.abs(postfix[i] - prefix[i-1])) Math.min Math res Math.abs(postfix[i] - prefix[i-1]) Math.abs Math postfix[i] - prefix[i-1] postfix[i] postfix i prefix[i-1] prefix i-1 i 1 System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] prefix = new int[n];
		int[] postfix = new int[n];
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++) {
			int w = sc.nextInt();
			nums[i] = w;
		}
		
		prefix[0] = nums[0];
		
		for (int i = 1; i < nums.length; i++) {
			prefix[i] = nums[i] + prefix[i-1];
		}

		postfix[n-1] = nums[n-1];
		
		for (int i = n - 2; i >= 0; i--) {
			postfix[i] = postfix[i+1] + nums[i];
		}

		int res = Integer.MAX_VALUE;
		
		for (int i = 1; i < n; i++) {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		}
		
		System.out.println(res);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] prefix = new int[n];
		int[] postfix = new int[n];
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++) {
			int w = sc.nextInt();
			nums[i] = w;
		}
		
		prefix[0] = nums[0];
		
		for (int i = 1; i < nums.length; i++) {
			prefix[i] = nums[i] + prefix[i-1];
		}

		postfix[n-1] = nums[n-1];
		
		for (int i = n - 2; i >= 0; i--) {
			postfix[i] = postfix[i+1] + nums[i];
		}

		int res = Integer.MAX_VALUE;
		
		for (int i = 1; i < n; i++) {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		}
		
		System.out.println(res);
	}

} 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[] prefix = new int[n];
		int[] postfix = new int[n];
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++) {
			int w = sc.nextInt();
			nums[i] = w;
		}
		
		prefix[0] = nums[0];
		
		for (int i = 1; i < nums.length; i++) {
			prefix[i] = nums[i] + prefix[i-1];
		}

		postfix[n-1] = nums[n-1];
		
		for (int i = n - 2; i >= 0; i--) {
			postfix[i] = postfix[i+1] + nums[i];
		}

		int res = Integer.MAX_VALUE;
		
		for (int i = 1; i < n; i++) {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		}
		
		System.out.println(res);
	}

}