

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		sc.close();
		
		int[] L = new int[N+1];
		int[] R = new int[N+1];
		
		int temp = 0;
		for (int i=0;i<N;i++) {
			temp+=A[i];
			L[i+1]=temp;
		}
		temp = 0;
		for (int i=N-1;i>-1;i--) {
			temp+=A[i];
			R[i+1]=temp;
		}
		int ans = 10000000;
		for (int i=0;i<N;i++) {
			ans = Math.min(ans, Math.abs(L[i]-R[i+1]));
		}
		
		System.out.println(ans);
	}

} 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[] A = new int[N];
		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		sc.close();
		
		int[] L = new int[N+1];
		int[] R = new int[N+1];
		
		int temp = 0;
		for (int i=0;i<N;i++) {
			temp+=A[i];
			L[i+1]=temp;
		}
		temp = 0;
		for (int i=N-1;i>-1;i--) {
			temp+=A[i];
			R[i+1]=temp;
		}
		int ans = 10000000;
		for (int i=0;i<N;i++) {
			ans = Math.min(ans, Math.abs(L[i]-R[i+1]));
		}
		
		System.out.println(ans);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		sc.close();
		
		int[] L = new int[N+1];
		int[] R = new int[N+1];
		
		int temp = 0;
		for (int i=0;i<N;i++) {
			temp+=A[i];
			L[i+1]=temp;
		}
		temp = 0;
		for (int i=N-1;i>-1;i--) {
			temp+=A[i];
			R[i+1]=temp;
		}
		int ans = 10000000;
		for (int i=0;i<N;i++) {
			ans = Math.min(ans, Math.abs(L[i]-R[i+1]));
		}
		
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		sc.close();
		
		int[] L = new int[N+1];
		int[] R = new int[N+1];
		
		int temp = 0;
		for (int i=0;i<N;i++) {
			temp+=A[i];
			L[i+1]=temp;
		}
		temp = 0;
		for (int i=N-1;i>-1;i--) {
			temp+=A[i];
			R[i+1]=temp;
		}
		int ans = 10000000;
		for (int i=0;i<N;i++) {
			ans = Math.min(ans, Math.abs(L[i]-R[i+1]));
		}
		
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] A = new int[N]; A new int[N] N for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			A[i]=sc.nextInt();
		} {
			A[i]=sc.nextInt();
		} A[i]=sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc sc.close() sc.close sc int[] L = new int[N+1]; L new int[N+1] N+1 N 1 int[] R = new int[N+1]; R new int[N+1] N+1 N 1 int temp = 0; temp 0 for (int i=0;i<N;i++) {
			temp+=A[i];
			L[i+1]=temp;
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			temp+=A[i];
			L[i+1]=temp;
		} {
			temp+=A[i];
			L[i+1]=temp;
		} temp+=A[i] temp A[i] A i L[i+1]=temp L[i+1] L i+1 i 1 temp temp = 0 temp 0 for (int i=N-1;i>-1;i--) {
			temp+=A[i];
			R[i+1]=temp;
		} int i=N-1; int i=N-1; i N-1 N 1 i>-1 i -1 1 i-- i-- i {
			temp+=A[i];
			R[i+1]=temp;
		} {
			temp+=A[i];
			R[i+1]=temp;
		} temp+=A[i] temp A[i] A i R[i+1]=temp R[i+1] R i+1 i 1 temp int ans = 10000000; ans 10000000 for (int i=0;i<N;i++) {
			ans = Math.min(ans, Math.abs(L[i]-R[i+1]));
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			ans = Math.min(ans, Math.abs(L[i]-R[i+1]));
		} {
			ans = Math.min(ans, Math.abs(L[i]-R[i+1]));
		} ans = Math.min(ans, Math.abs(L[i]-R[i+1])) ans Math.min(ans, Math.abs(L[i]-R[i+1])) Math.min Math ans Math.abs(L[i]-R[i+1]) Math.abs Math L[i]-R[i+1] L[i] L i R[i+1] R i+1 i 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		sc.close();
		
		int[] L = new int[N+1];
		int[] R = new int[N+1];
		
		int temp = 0;
		for (int i=0;i<N;i++) {
			temp+=A[i];
			L[i+1]=temp;
		}
		temp = 0;
		for (int i=N-1;i>-1;i--) {
			temp+=A[i];
			R[i+1]=temp;
		}
		int ans = 10000000;
		for (int i=0;i<N;i++) {
			ans = Math.min(ans, Math.abs(L[i]-R[i+1]));
		}
		
		System.out.println(ans);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		sc.close();
		
		int[] L = new int[N+1];
		int[] R = new int[N+1];
		
		int temp = 0;
		for (int i=0;i<N;i++) {
			temp+=A[i];
			L[i+1]=temp;
		}
		temp = 0;
		for (int i=N-1;i>-1;i--) {
			temp+=A[i];
			R[i+1]=temp;
		}
		int ans = 10000000;
		for (int i=0;i<N;i++) {
			ans = Math.min(ans, Math.abs(L[i]-R[i+1]));
		}
		
		System.out.println(ans);
	}

} 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[] A = new int[N];
		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		sc.close();
		
		int[] L = new int[N+1];
		int[] R = new int[N+1];
		
		int temp = 0;
		for (int i=0;i<N;i++) {
			temp+=A[i];
			L[i+1]=temp;
		}
		temp = 0;
		for (int i=N-1;i>-1;i--) {
			temp+=A[i];
			R[i+1]=temp;
		}
		int ans = 10000000;
		for (int i=0;i<N;i++) {
			ans = Math.min(ans, Math.abs(L[i]-R[i+1]));
		}
		
		System.out.println(ans);
	}

}
