import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int Weight[] = new int[N];
		int S1 = 0;
		int S2 = 0;
		int Number = 0;
		int data[] = new int[N];
		for (int i = 0;i < N; i++) {
			int x = scanner.nextInt();
			Weight[i] = x;
		}

		for (int i = 0; i < N; i++) {
			S1 = 0;
			for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			}
			S2 = 0;
			for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			}
			// 			System.out.println("S1は" + S1);
			// 			System.out.println("S2は" + S2);
			if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			}
			data[i] = Number;
			// 			System.out.println(data[i]);
		}

		//		for (int i=0; i<data.length; i++) {
		//			if (min > data[i]) {	//現在の最小値よりも小さい値が出たら
		//				min = data[i];	//変数minに値を入れ替える
		//			}
		//		}
		//		System.out.println(min);
		// 最小値を求める
		int min = data[0];
		for(int i = 0; i < data.length; i++)
			min = Math.min(min,data[i]);
		System.out.println(min);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int Weight[] = new int[N];
		int S1 = 0;
		int S2 = 0;
		int Number = 0;
		int data[] = new int[N];
		for (int i = 0;i < N; i++) {
			int x = scanner.nextInt();
			Weight[i] = x;
		}

		for (int i = 0; i < N; i++) {
			S1 = 0;
			for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			}
			S2 = 0;
			for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			}
			// 			System.out.println("S1は" + S1);
			// 			System.out.println("S2は" + S2);
			if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			}
			data[i] = Number;
			// 			System.out.println(data[i]);
		}

		//		for (int i=0; i<data.length; i++) {
		//			if (min > data[i]) {	//現在の最小値よりも小さい値が出たら
		//				min = data[i];	//変数minに値を入れ替える
		//			}
		//		}
		//		System.out.println(min);
		// 最小値を求める
		int min = data[0];
		for(int i = 0; i < data.length; i++)
			min = Math.min(min,data[i]);
		System.out.println(min);
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int Weight[] = new int[N];
		int S1 = 0;
		int S2 = 0;
		int Number = 0;
		int data[] = new int[N];
		for (int i = 0;i < N; i++) {
			int x = scanner.nextInt();
			Weight[i] = x;
		}

		for (int i = 0; i < N; i++) {
			S1 = 0;
			for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			}
			S2 = 0;
			for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			}
			// 			System.out.println("S1は" + S1);
			// 			System.out.println("S2は" + S2);
			if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			}
			data[i] = Number;
			// 			System.out.println(data[i]);
		}

		//		for (int i=0; i<data.length; i++) {
		//			if (min > data[i]) {	//現在の最小値よりも小さい値が出たら
		//				min = data[i];	//変数minに値を入れ替える
		//			}
		//		}
		//		System.out.println(min);
		// 最小値を求める
		int min = data[0];
		for(int i = 0; i < data.length; i++)
			min = Math.min(min,data[i]);
		System.out.println(min);
	} main {
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int Weight[] = new int[N];
		int S1 = 0;
		int S2 = 0;
		int Number = 0;
		int data[] = new int[N];
		for (int i = 0;i < N; i++) {
			int x = scanner.nextInt();
			Weight[i] = x;
		}

		for (int i = 0; i < N; i++) {
			S1 = 0;
			for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			}
			S2 = 0;
			for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			}
			// 			System.out.println("S1は" + S1);
			// 			System.out.println("S2は" + S2);
			if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			}
			data[i] = Number;
			// 			System.out.println(data[i]);
		}

		//		for (int i=0; i<data.length; i++) {
		//			if (min > data[i]) {	//現在の最小値よりも小さい値が出たら
		//				min = data[i];	//変数minに値を入れ替える
		//			}
		//		}
		//		System.out.println(min);
		// 最小値を求める
		int min = data[0];
		for(int i = 0; i < data.length; i++)
			min = Math.min(min,data[i]);
		System.out.println(min);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int Weight[] = new int[N]; Weight new int[N] N int S1 = 0; S1 0 int S2 = 0; S2 0 int Number = 0; Number 0 int data[] = new int[N]; data new int[N] N for (int i = 0;i < N; i++) {
			int x = scanner.nextInt();
			Weight[i] = x;
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int x = scanner.nextInt();
			Weight[i] = x;
		} {
			int x = scanner.nextInt();
			Weight[i] = x;
		} int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner Weight[i] = x Weight[i] Weight i x for (int i = 0; i < N; i++) {
			S1 = 0;
			for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			}
			S2 = 0;
			for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			}
			// 			System.out.println("S1は" + S1);
			// 			System.out.println("S2は" + S2);
			if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			}
			data[i] = Number;
			// 			System.out.println(data[i]);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			S1 = 0;
			for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			}
			S2 = 0;
			for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			}
			// 			System.out.println("S1は" + S1);
			// 			System.out.println("S2は" + S2);
			if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			}
			data[i] = Number;
			// 			System.out.println(data[i]);
		} {
			S1 = 0;
			for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			}
			S2 = 0;
			for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			}
			// 			System.out.println("S1は" + S1);
			// 			System.out.println("S2は" + S2);
			if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			}
			data[i] = Number;
			// 			System.out.println(data[i]);
		} S1 = 0 S1 0 for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			} int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
				S1 += Weight[j];
			} {
				S1 += Weight[j];
			} S1 += Weight[j] S1 Weight[j] Weight j S2 = 0 S2 0 for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			} int k = i; int k = i; k i k < N k N k++ k++ k {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			} {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			} S2 += Weight[k] S2 Weight[k] Weight k if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			} S2 - S1 >= 0 S2 - S1 S2 S1 0 {
				Number = S2 - S1;
			} Number = S2 - S1 Number S2 - S1 S2 S1 {
				Number = S1 - S2;
			} Number = S1 - S2 Number S1 - S2 S1 S2 data[i] = Number data[i] data i Number int min = data[0]; min data[0] data 0 for(int i = 0; i < data.length; i++)
			min = Math.min(min,data[i]); int i = 0; int i = 0; i 0 i < data.length i data.length data data.length i++ i++ i min = Math.min(min,data[i]); min = Math.min(min,data[i]) min Math.min(min,data[i]) Math.min Math min data[i] data i System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int Weight[] = new int[N];
		int S1 = 0;
		int S2 = 0;
		int Number = 0;
		int data[] = new int[N];
		for (int i = 0;i < N; i++) {
			int x = scanner.nextInt();
			Weight[i] = x;
		}

		for (int i = 0; i < N; i++) {
			S1 = 0;
			for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			}
			S2 = 0;
			for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			}
			// 			System.out.println("S1は" + S1);
			// 			System.out.println("S2は" + S2);
			if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			}
			data[i] = Number;
			// 			System.out.println(data[i]);
		}

		//		for (int i=0; i<data.length; i++) {
		//			if (min > data[i]) {	//現在の最小値よりも小さい値が出たら
		//				min = data[i];	//変数minに値を入れ替える
		//			}
		//		}
		//		System.out.println(min);
		// 最小値を求める
		int min = data[0];
		for(int i = 0; i < data.length; i++)
			min = Math.min(min,data[i]);
		System.out.println(min);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int Weight[] = new int[N];
		int S1 = 0;
		int S2 = 0;
		int Number = 0;
		int data[] = new int[N];
		for (int i = 0;i < N; i++) {
			int x = scanner.nextInt();
			Weight[i] = x;
		}

		for (int i = 0; i < N; i++) {
			S1 = 0;
			for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			}
			S2 = 0;
			for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			}
			// 			System.out.println("S1は" + S1);
			// 			System.out.println("S2は" + S2);
			if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			}
			data[i] = Number;
			// 			System.out.println(data[i]);
		}

		//		for (int i=0; i<data.length; i++) {
		//			if (min > data[i]) {	//現在の最小値よりも小さい値が出たら
		//				min = data[i];	//変数minに値を入れ替える
		//			}
		//		}
		//		System.out.println(min);
		// 最小値を求める
		int min = data[0];
		for(int i = 0; i < data.length; i++)
			min = Math.min(min,data[i]);
		System.out.println(min);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int Weight[] = new int[N];
		int S1 = 0;
		int S2 = 0;
		int Number = 0;
		int data[] = new int[N];
		for (int i = 0;i < N; i++) {
			int x = scanner.nextInt();
			Weight[i] = x;
		}

		for (int i = 0; i < N; i++) {
			S1 = 0;
			for (int j = 0; j < i; j++) {
				S1 += Weight[j];
			}
			S2 = 0;
			for (int k = i; k < N; k++) {
				//System.out.println("どうかな" + Weight[k]);
				S2 += Weight[k];
				//System.out.println("1個ずつ" + S2);
			}
			// 			System.out.println("S1は" + S1);
			// 			System.out.println("S2は" + S2);
			if (S2 - S1 >= 0) {
				Number = S2 - S1;
			} else {
				Number = S1 - S2;
			}
			data[i] = Number;
			// 			System.out.println(data[i]);
		}

		//		for (int i=0; i<data.length; i++) {
		//			if (min > data[i]) {	//現在の最小値よりも小さい値が出たら
		//				min = data[i];	//変数minに値を入れ替える
		//			}
		//		}
		//		System.out.println(min);
		// 最小値を求める
		int min = data[0];
		for(int i = 0; i < data.length; i++)
			min = Math.min(min,data[i]);
		System.out.println(min);
	}
}