import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		int num = sn.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < num; i++) {
			list.add(sn.nextInt());
		}

		List<Integer> min = new ArrayList<Integer>();

		for (int t = 0; t < num; t++) {
			int S1 = 0;
			int S2 = 0;

			// S1
			for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			}
			// S2
			for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			}

			min.add(Math.abs(S1 - S2));
		}

		Collections.sort(min);

		System.out.println(min.get(0));
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

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

		int num = sn.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < num; i++) {
			list.add(sn.nextInt());
		}

		List<Integer> min = new ArrayList<Integer>();

		for (int t = 0; t < num; t++) {
			int S1 = 0;
			int S2 = 0;

			// S1
			for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			}
			// S2
			for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			}

			min.add(Math.abs(S1 - S2));
		}

		Collections.sort(min);

		System.out.println(min.get(0));
	}
} Main public static void main(String[] args) {
		Scanner sn = new Scanner(System.in);

		int num = sn.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < num; i++) {
			list.add(sn.nextInt());
		}

		List<Integer> min = new ArrayList<Integer>();

		for (int t = 0; t < num; t++) {
			int S1 = 0;
			int S2 = 0;

			// S1
			for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			}
			// S2
			for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			}

			min.add(Math.abs(S1 - S2));
		}

		Collections.sort(min);

		System.out.println(min.get(0));
	} main {
		Scanner sn = new Scanner(System.in);

		int num = sn.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < num; i++) {
			list.add(sn.nextInt());
		}

		List<Integer> min = new ArrayList<Integer>();

		for (int t = 0; t < num; t++) {
			int S1 = 0;
			int S2 = 0;

			// S1
			for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			}
			// S2
			for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			}

			min.add(Math.abs(S1 - S2));
		}

		Collections.sort(min);

		System.out.println(min.get(0));
	} Scanner sn = new Scanner(System.in); sn new Scanner(System.in) int num = sn.nextInt(); num sn.nextInt() sn.nextInt sn List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for (int i = 0; i < num; i++) {
			list.add(sn.nextInt());
		} int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
			list.add(sn.nextInt());
		} {
			list.add(sn.nextInt());
		} list.add(sn.nextInt()) list.add list sn.nextInt() sn.nextInt sn List<Integer> min = new ArrayList<Integer>(); min new ArrayList<Integer>() for (int t = 0; t < num; t++) {
			int S1 = 0;
			int S2 = 0;

			// S1
			for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			}
			// S2
			for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			}

			min.add(Math.abs(S1 - S2));
		} int t = 0; int t = 0; t 0 t < num t num t++ t++ t {
			int S1 = 0;
			int S2 = 0;

			// S1
			for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			}
			// S2
			for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			}

			min.add(Math.abs(S1 - S2));
		} {
			int S1 = 0;
			int S2 = 0;

			// S1
			for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			}
			// S2
			for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			}

			min.add(Math.abs(S1 - S2));
		} int S1 = 0; S1 0 int S2 = 0; S2 0 for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			} int i = 0; int i = 0; i 0 i <= t i t i++ i++ i {
				S1 = S1 + list.get(i);
			} {
				S1 = S1 + list.get(i);
			} S1 = S1 + list.get(i) S1 S1 + list.get(i) S1 list.get(i) list.get list i for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			} int i = t + 1; int i = t + 1; i t + 1 t 1 i < num i num i++ i++ i {
				S2 = S2 + list.get(i);
			} {
				S2 = S2 + list.get(i);
			} S2 = S2 + list.get(i) S2 S2 + list.get(i) S2 list.get(i) list.get list i min.add(Math.abs(S1 - S2)) min.add min Math.abs(S1 - S2) Math.abs Math S1 - S2 S1 S2 Collections.sort(min) Collections.sort Collections min System.out.println(min.get(0)) System.out.println System.out System System.out min.get(0) min.get min 0 String[] args args public class Main {

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

		int num = sn.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < num; i++) {
			list.add(sn.nextInt());
		}

		List<Integer> min = new ArrayList<Integer>();

		for (int t = 0; t < num; t++) {
			int S1 = 0;
			int S2 = 0;

			// S1
			for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			}
			// S2
			for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			}

			min.add(Math.abs(S1 - S2));
		}

		Collections.sort(min);

		System.out.println(min.get(0));
	}
} public class Main {

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

		int num = sn.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < num; i++) {
			list.add(sn.nextInt());
		}

		List<Integer> min = new ArrayList<Integer>();

		for (int t = 0; t < num; t++) {
			int S1 = 0;
			int S2 = 0;

			// S1
			for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			}
			// S2
			for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			}

			min.add(Math.abs(S1 - S2));
		}

		Collections.sort(min);

		System.out.println(min.get(0));
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		int num = sn.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < num; i++) {
			list.add(sn.nextInt());
		}

		List<Integer> min = new ArrayList<Integer>();

		for (int t = 0; t < num; t++) {
			int S1 = 0;
			int S2 = 0;

			// S1
			for (int i = 0; i <= t; i++) {
				S1 = S1 + list.get(i);
			}
			// S2
			for (int i = t + 1; i < num; i++) {
				S2 = S2 + list.get(i);
			}

			min.add(Math.abs(S1 - S2));
		}

		Collections.sort(min);

		System.out.println(min.get(0));
	}
}
