import java.util.Scanner;
import java.lang.Math;

public class Main {
	
	int sum(int[] a, int[] b) {
		
		
		return 0;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0 ;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		int[] sumForward = new int[n];
		sumForward[0] = arr[0];
		for(int i = 1;i<n;i++) {
			sumForward[i] = sumForward[i-1]+arr[i];
		}
		int[] sumBackward = new int[n];
		sumBackward[n-1] = arr[n-1];
		for(int i = n-2; i>=0;i--) {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		}
		int min = Math.abs(sumForward[0] - sumBackward[1]);
		for(int i = 0 ;i<n-1;i++) {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		}
		System.out.println(min);
	}

} import java.util.Scanner; Scanner java.util import java.lang.Math; Math java.lang public class Main {
	
	int sum(int[] a, int[] b) {
		
		
		return 0;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0 ;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		int[] sumForward = new int[n];
		sumForward[0] = arr[0];
		for(int i = 1;i<n;i++) {
			sumForward[i] = sumForward[i-1]+arr[i];
		}
		int[] sumBackward = new int[n];
		sumBackward[n-1] = arr[n-1];
		for(int i = n-2; i>=0;i--) {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		}
		int min = Math.abs(sumForward[0] - sumBackward[1]);
		for(int i = 0 ;i<n-1;i++) {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		}
		System.out.println(min);
	}

} Main int sum(int[] a, int[] b) {
		
		
		return 0;
	} sum {
		
		
		return 0;
	} return 0; 0 int[] a a int[] b b public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0 ;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		int[] sumForward = new int[n];
		sumForward[0] = arr[0];
		for(int i = 1;i<n;i++) {
			sumForward[i] = sumForward[i-1]+arr[i];
		}
		int[] sumBackward = new int[n];
		sumBackward[n-1] = arr[n-1];
		for(int i = n-2; i>=0;i--) {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		}
		int min = Math.abs(sumForward[0] - sumBackward[1]);
		for(int i = 0 ;i<n-1;i++) {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		}
		System.out.println(min);
	} main {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0 ;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		int[] sumForward = new int[n];
		sumForward[0] = arr[0];
		for(int i = 1;i<n;i++) {
			sumForward[i] = sumForward[i-1]+arr[i];
		}
		int[] sumBackward = new int[n];
		sumBackward[n-1] = arr[n-1];
		for(int i = n-2; i>=0;i--) {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		}
		int min = Math.abs(sumForward[0] - sumBackward[1]);
		for(int i = 0 ;i<n-1;i++) {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		}
		System.out.println(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] arr = new int[n]; arr new int[n] n for(int i = 0 ;i<n;i++) {
			arr[i] = sc.nextInt();
		} int i = 0 ; int i = 0 ; i 0 i<n i n i++ i++ i {
			arr[i] = sc.nextInt();
		} {
			arr[i] = sc.nextInt();
		} arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc int[] sumForward = new int[n]; sumForward new int[n] n sumForward[0] = arr[0] sumForward[0] sumForward 0 arr[0] arr 0 for(int i = 1;i<n;i++) {
			sumForward[i] = sumForward[i-1]+arr[i];
		} int i = 1; int i = 1; i 1 i<n i n i++ i++ i {
			sumForward[i] = sumForward[i-1]+arr[i];
		} {
			sumForward[i] = sumForward[i-1]+arr[i];
		} sumForward[i] = sumForward[i-1]+arr[i] sumForward[i] sumForward i sumForward[i-1]+arr[i] sumForward[i-1] sumForward i-1 i 1 arr[i] arr i int[] sumBackward = new int[n]; sumBackward new int[n] n sumBackward[n-1] = arr[n-1] sumBackward[n-1] sumBackward n-1 n 1 arr[n-1] arr n-1 n 1 for(int i = n-2; i>=0;i--) {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		} int i = n-2; int i = n-2; i n-2 n 2 i>=0 i 0 i-- i-- i {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		} {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		} sumBackward[i] = sumBackward[i+1]+arr[i] sumBackward[i] sumBackward i sumBackward[i+1]+arr[i] sumBackward[i+1] sumBackward i+1 i 1 arr[i] arr i int min = Math.abs(sumForward[0] - sumBackward[1]); min Math.abs(sumForward[0] - sumBackward[1]) Math.abs Math sumForward[0] - sumBackward[1] sumForward[0] sumForward 0 sumBackward[1] sumBackward 1 for(int i = 0 ;i<n-1;i++) {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		} int i = 0 ; int i = 0 ; i 0 i<n-1 i n-1 n 1 i++ i++ i {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		} {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		} if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			} min>Math.abs(sumForward[i]-sumBackward[i+1]) min Math.abs(sumForward[i]-sumBackward[i+1]) Math.abs Math sumForward[i]-sumBackward[i+1] sumForward[i] sumForward i sumBackward[i+1] sumBackward i+1 i 1 {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			} min = Math.abs(sumForward[i]-sumBackward[i+1]) min Math.abs(sumForward[i]-sumBackward[i+1]) Math.abs Math sumForward[i]-sumBackward[i+1] sumForward[i] sumForward i sumBackward[i+1] sumBackward i+1 i 1 System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {
	
	int sum(int[] a, int[] b) {
		
		
		return 0;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0 ;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		int[] sumForward = new int[n];
		sumForward[0] = arr[0];
		for(int i = 1;i<n;i++) {
			sumForward[i] = sumForward[i-1]+arr[i];
		}
		int[] sumBackward = new int[n];
		sumBackward[n-1] = arr[n-1];
		for(int i = n-2; i>=0;i--) {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		}
		int min = Math.abs(sumForward[0] - sumBackward[1]);
		for(int i = 0 ;i<n-1;i++) {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		}
		System.out.println(min);
	}

} public class Main {
	
	int sum(int[] a, int[] b) {
		
		
		return 0;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0 ;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		int[] sumForward = new int[n];
		sumForward[0] = arr[0];
		for(int i = 1;i<n;i++) {
			sumForward[i] = sumForward[i-1]+arr[i];
		}
		int[] sumBackward = new int[n];
		sumBackward[n-1] = arr[n-1];
		for(int i = n-2; i>=0;i--) {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		}
		int min = Math.abs(sumForward[0] - sumBackward[1]);
		for(int i = 0 ;i<n-1;i++) {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		}
		System.out.println(min);
	}

} Main
import java.util.Scanner;
import java.lang.Math;

public class Main {
	
	int sum(int[] a, int[] b) {
		
		
		return 0;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0 ;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		int[] sumForward = new int[n];
		sumForward[0] = arr[0];
		for(int i = 1;i<n;i++) {
			sumForward[i] = sumForward[i-1]+arr[i];
		}
		int[] sumBackward = new int[n];
		sumBackward[n-1] = arr[n-1];
		for(int i = n-2; i>=0;i--) {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		}
		int min = Math.abs(sumForward[0] - sumBackward[1]);
		for(int i = 0 ;i<n-1;i++) {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		}
		System.out.println(min);
	}

}
