import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []w = new int [n];
		
		for(int i =0; i < n ; i++) {
			 w [i] = sc.nextInt();		
		}
		int t1 = 0;
		int t2 = 0 ;
		int k = 0;
		int l = 0;
		
		while(k + l < n  ) {
			if(t1 <= t2) {
				t1 = w[k] + t1;
			k++;}
			
			else {
				t2 = w [n - 1 - l]  + t2;
			l++;
			}
		}
		 int ans = Math.abs(t2-t1);
		 System.out.println(ans);
				
		
		}
	
	 
	
	}

 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []w = new int [n];
		
		for(int i =0; i < n ; i++) {
			 w [i] = sc.nextInt();		
		}
		int t1 = 0;
		int t2 = 0 ;
		int k = 0;
		int l = 0;
		
		while(k + l < n  ) {
			if(t1 <= t2) {
				t1 = w[k] + t1;
			k++;}
			
			else {
				t2 = w [n - 1 - l]  + t2;
			l++;
			}
		}
		 int ans = Math.abs(t2-t1);
		 System.out.println(ans);
				
		
		}
	
	 
	
	} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []w = new int [n];
		
		for(int i =0; i < n ; i++) {
			 w [i] = sc.nextInt();		
		}
		int t1 = 0;
		int t2 = 0 ;
		int k = 0;
		int l = 0;
		
		while(k + l < n  ) {
			if(t1 <= t2) {
				t1 = w[k] + t1;
			k++;}
			
			else {
				t2 = w [n - 1 - l]  + t2;
			l++;
			}
		}
		 int ans = Math.abs(t2-t1);
		 System.out.println(ans);
				
		
		} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []w = new int [n];
		
		for(int i =0; i < n ; i++) {
			 w [i] = sc.nextInt();		
		}
		int t1 = 0;
		int t2 = 0 ;
		int k = 0;
		int l = 0;
		
		while(k + l < n  ) {
			if(t1 <= t2) {
				t1 = w[k] + t1;
			k++;}
			
			else {
				t2 = w [n - 1 - l]  + t2;
			l++;
			}
		}
		 int ans = Math.abs(t2-t1);
		 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 []w = new int [n]; w new int [n] n for(int i =0; i < n ; i++) {
			 w [i] = sc.nextInt();		
		} int i =0; int i =0; i 0 i < n i n i++ i++ i {
			 w [i] = sc.nextInt();		
		} {
			 w [i] = sc.nextInt();		
		} w [i] = sc.nextInt() w [i] w i sc.nextInt() sc.nextInt sc int t1 = 0; t1 0 int t2 = 0 ; t2 0 int k = 0; k 0 int l = 0; l 0 while(k + l < n  ) {
			if(t1 <= t2) {
				t1 = w[k] + t1;
			k++;}
			
			else {
				t2 = w [n - 1 - l]  + t2;
			l++;
			}
		} k + l < n k + l k l n {
			if(t1 <= t2) {
				t1 = w[k] + t1;
			k++;}
			
			else {
				t2 = w [n - 1 - l]  + t2;
			l++;
			}
		} if(t1 <= t2) {
				t1 = w[k] + t1;
			k++;}
			
			else {
				t2 = w [n - 1 - l]  + t2;
			l++;
			} t1 <= t2 t1 t2 {
				t1 = w[k] + t1;
			k++;} t1 = w[k] + t1 t1 w[k] + t1 w[k] w k t1 k++ k {
				t2 = w [n - 1 - l]  + t2;
			l++;
			} t2 = w [n - 1 - l]  + t2 t2 w [n - 1 - l]  + t2 w [n - 1 - l] w n - 1 - l n - 1 - l n 1 l t2 l++ l int ans = Math.abs(t2-t1); ans Math.abs(t2-t1) Math.abs Math t2-t1 t2 t1 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) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []w = new int [n];
		
		for(int i =0; i < n ; i++) {
			 w [i] = sc.nextInt();		
		}
		int t1 = 0;
		int t2 = 0 ;
		int k = 0;
		int l = 0;
		
		while(k + l < n  ) {
			if(t1 <= t2) {
				t1 = w[k] + t1;
			k++;}
			
			else {
				t2 = w [n - 1 - l]  + t2;
			l++;
			}
		}
		 int ans = Math.abs(t2-t1);
		 System.out.println(ans);
				
		
		}
	
	 
	
	} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []w = new int [n];
		
		for(int i =0; i < n ; i++) {
			 w [i] = sc.nextInt();		
		}
		int t1 = 0;
		int t2 = 0 ;
		int k = 0;
		int l = 0;
		
		while(k + l < n  ) {
			if(t1 <= t2) {
				t1 = w[k] + t1;
			k++;}
			
			else {
				t2 = w [n - 1 - l]  + t2;
			l++;
			}
		}
		 int ans = Math.abs(t2-t1);
		 System.out.println(ans);
				
		
		}
	
	 
	
	} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []w = new int [n];
		
		for(int i =0; i < n ; i++) {
			 w [i] = sc.nextInt();		
		}
		int t1 = 0;
		int t2 = 0 ;
		int k = 0;
		int l = 0;
		
		while(k + l < n  ) {
			if(t1 <= t2) {
				t1 = w[k] + t1;
			k++;}
			
			else {
				t2 = w [n - 1 - l]  + t2;
			l++;
			}
		}
		 int ans = Math.abs(t2-t1);
		 System.out.println(ans);
				
		
		}
	
	 
	
	}


