import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		int num;
		String[] weight;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){

			String n = br.readLine();
			String w = br.readLine();

			num = Integer.parseInt(n);
			weight = w.split(" ");
		} catch (IOException e) {

			return;
		}
		int minDiff = Integer.MAX_VALUE;
		for (int t = 1; t < num; t++) {

			int s1 = 0;
			for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			}
			int s2 = 0;
			for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			}
			if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			}
		}
		System.out.println(minDiff);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) {

		int num;
		String[] weight;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){

			String n = br.readLine();
			String w = br.readLine();

			num = Integer.parseInt(n);
			weight = w.split(" ");
		} catch (IOException e) {

			return;
		}
		int minDiff = Integer.MAX_VALUE;
		for (int t = 1; t < num; t++) {

			int s1 = 0;
			for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			}
			int s2 = 0;
			for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			}
			if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			}
		}
		System.out.println(minDiff);
	}
} Main public static void main(String[] args) {

		int num;
		String[] weight;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){

			String n = br.readLine();
			String w = br.readLine();

			num = Integer.parseInt(n);
			weight = w.split(" ");
		} catch (IOException e) {

			return;
		}
		int minDiff = Integer.MAX_VALUE;
		for (int t = 1; t < num; t++) {

			int s1 = 0;
			for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			}
			int s2 = 0;
			for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			}
			if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			}
		}
		System.out.println(minDiff);
	} main {

		int num;
		String[] weight;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){

			String n = br.readLine();
			String w = br.readLine();

			num = Integer.parseInt(n);
			weight = w.split(" ");
		} catch (IOException e) {

			return;
		}
		int minDiff = Integer.MAX_VALUE;
		for (int t = 1; t < num; t++) {

			int s1 = 0;
			for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			}
			int s2 = 0;
			for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			}
			if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			}
		}
		System.out.println(minDiff);
	} int num; num String[] weight; weight try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){

			String n = br.readLine();
			String w = br.readLine();

			num = Integer.parseInt(n);
			weight = w.split(" ");
		} catch (IOException e) {

			return;
		} catch (IOException e) {

			return;
		} IOException e {

			return;
		} return; {

			String n = br.readLine();
			String w = br.readLine();

			num = Integer.parseInt(n);
			weight = w.split(" ");
		} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String n = br.readLine(); n br.readLine() br.readLine br String w = br.readLine(); w br.readLine() br.readLine br num = Integer.parseInt(n) num Integer.parseInt(n) Integer.parseInt Integer n weight = w.split(" ") weight w.split(" ") w.split w " " int minDiff = Integer.MAX_VALUE; minDiff Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int t = 1; t < num; t++) {

			int s1 = 0;
			for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			}
			int s2 = 0;
			for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			}
			if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			}
		} int t = 1; int t = 1; t 1 t < num t num t++ t++ t {

			int s1 = 0;
			for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			}
			int s2 = 0;
			for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			}
			if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			}
		} {

			int s1 = 0;
			for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			}
			int s2 = 0;
			for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			}
			if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			}
		} int s1 = 0; s1 0 for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			} int index = 0; int index = 0; index 0 index < t index t index ++ index ++ index {

				s1 += Integer.parseInt(weight[index]);
			} {

				s1 += Integer.parseInt(weight[index]);
			} s1 += Integer.parseInt(weight[index]) s1 Integer.parseInt(weight[index]) Integer.parseInt Integer weight[index] weight index int s2 = 0; s2 0 for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			} int index = t; int index = t; index t index < num index num index ++ index ++ index {

				s2 += Integer.parseInt(weight[index]);
			} {

				s2 += Integer.parseInt(weight[index]);
			} s2 += Integer.parseInt(weight[index]) s2 Integer.parseInt(weight[index]) Integer.parseInt Integer weight[index] weight index if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			} minDiff > Math.abs(s1 - s2) minDiff Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 {

				minDiff = Math.abs(s1 - s2);
			} minDiff = Math.abs(s1 - s2) minDiff Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 System.out.println(minDiff) System.out.println System.out System System.out minDiff String[] args args public class Main {

	public static void main(String[] args) {

		int num;
		String[] weight;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){

			String n = br.readLine();
			String w = br.readLine();

			num = Integer.parseInt(n);
			weight = w.split(" ");
		} catch (IOException e) {

			return;
		}
		int minDiff = Integer.MAX_VALUE;
		for (int t = 1; t < num; t++) {

			int s1 = 0;
			for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			}
			int s2 = 0;
			for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			}
			if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			}
		}
		System.out.println(minDiff);
	}
} public class Main {

	public static void main(String[] args) {

		int num;
		String[] weight;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){

			String n = br.readLine();
			String w = br.readLine();

			num = Integer.parseInt(n);
			weight = w.split(" ");
		} catch (IOException e) {

			return;
		}
		int minDiff = Integer.MAX_VALUE;
		for (int t = 1; t < num; t++) {

			int s1 = 0;
			for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			}
			int s2 = 0;
			for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			}
			if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			}
		}
		System.out.println(minDiff);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		int num;
		String[] weight;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){

			String n = br.readLine();
			String w = br.readLine();

			num = Integer.parseInt(n);
			weight = w.split(" ");
		} catch (IOException e) {

			return;
		}
		int minDiff = Integer.MAX_VALUE;
		for (int t = 1; t < num; t++) {

			int s1 = 0;
			for (int index = 0; index < t; index ++) {

				s1 += Integer.parseInt(weight[index]);
			}
			int s2 = 0;
			for (int index = t; index < num; index ++) {

				s2 += Integer.parseInt(weight[index]);
			}
			if (minDiff > Math.abs(s1 - s2)) {

				minDiff = Math.abs(s1 - s2);
			}
		}
		System.out.println(minDiff);
	}
}
