import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int[] a = new int[N];
		for(int i=0;i<N;i++) {
			a[i]=nextInt();
		}
		sc.close();
		int[] L = new int[N];
		int[] R = new int[N];
		L[N-1] = a[N-1];
		for(int i=0;i<N-1;i++) {
			L[i]+=a[i];
			L[i+1]+=L[i];
		}
		R[0] = a[0];
		for(int i=N-1;i>0;i--) {
			R[i]+=a[i];
			R[i-1]+=R[i];
		}
		int minabs = 100010;
		for(int i=0;i<N-1;i++) {
			minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs);
		}
		out.println(minabs);
	}

	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}
} import java.io.PrintStream; PrintStream java.io import java.util.Scanner; Scanner java.util public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int[] a = new int[N];
		for(int i=0;i<N;i++) {
			a[i]=nextInt();
		}
		sc.close();
		int[] L = new int[N];
		int[] R = new int[N];
		L[N-1] = a[N-1];
		for(int i=0;i<N-1;i++) {
			L[i]+=a[i];
			L[i+1]+=L[i];
		}
		R[0] = a[0];
		for(int i=N-1;i>0;i--) {
			R[i]+=a[i];
			R[i-1]+=R[i];
		}
		int minabs = 100010;
		for(int i=0;i<N-1;i++) {
			minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs);
		}
		out.println(minabs);
	}

	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}
} Main static final PrintStream out = System.out; out System.out System System.out static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static final long Mod = 1000_000_007L; Mod 1000_000_007L public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	} main {
		Main main = new Main();
		main.solve();
		System.exit(0);
	} Main main = new Main(); main new Main() main.solve() main.solve main System.exit(0) System.exit System 0 String[] args args void solve() {
		int N = nextInt();
		int[] a = new int[N];
		for(int i=0;i<N;i++) {
			a[i]=nextInt();
		}
		sc.close();
		int[] L = new int[N];
		int[] R = new int[N];
		L[N-1] = a[N-1];
		for(int i=0;i<N-1;i++) {
			L[i]+=a[i];
			L[i+1]+=L[i];
		}
		R[0] = a[0];
		for(int i=N-1;i>0;i--) {
			R[i]+=a[i];
			R[i-1]+=R[i];
		}
		int minabs = 100010;
		for(int i=0;i<N-1;i++) {
			minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs);
		}
		out.println(minabs);
	} solve {
		int N = nextInt();
		int[] a = new int[N];
		for(int i=0;i<N;i++) {
			a[i]=nextInt();
		}
		sc.close();
		int[] L = new int[N];
		int[] R = new int[N];
		L[N-1] = a[N-1];
		for(int i=0;i<N-1;i++) {
			L[i]+=a[i];
			L[i+1]+=L[i];
		}
		R[0] = a[0];
		for(int i=N-1;i>0;i--) {
			R[i]+=a[i];
			R[i-1]+=R[i];
		}
		int minabs = 100010;
		for(int i=0;i<N-1;i++) {
			minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs);
		}
		out.println(minabs);
	} int N = nextInt(); N nextInt() nextInt int[] a = new int[N]; a new int[N] N for(int i=0;i<N;i++) {
			a[i]=nextInt();
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			a[i]=nextInt();
		} {
			a[i]=nextInt();
		} a[i]=nextInt() a[i] a i nextInt() nextInt sc.close() sc.close sc int[] L = new int[N]; L new int[N] N int[] R = new int[N]; R new int[N] N L[N-1] = a[N-1] L[N-1] L N-1 N 1 a[N-1] a N-1 N 1 for(int i=0;i<N-1;i++) {
			L[i]+=a[i];
			L[i+1]+=L[i];
		} int i=0; int i=0; i 0 i<N-1 i N-1 N 1 i++ i++ i {
			L[i]+=a[i];
			L[i+1]+=L[i];
		} {
			L[i]+=a[i];
			L[i+1]+=L[i];
		} L[i]+=a[i] L[i] L i a[i] a i L[i+1]+=L[i] L[i+1] L i+1 i 1 L[i] L i R[0] = a[0] R[0] R 0 a[0] a 0 for(int i=N-1;i>0;i--) {
			R[i]+=a[i];
			R[i-1]+=R[i];
		} int i=N-1; int i=N-1; i N-1 N 1 i>0 i 0 i-- i-- i {
			R[i]+=a[i];
			R[i-1]+=R[i];
		} {
			R[i]+=a[i];
			R[i-1]+=R[i];
		} R[i]+=a[i] R[i] R i a[i] a i R[i-1]+=R[i] R[i-1] R i-1 i 1 R[i] R i int minabs = 100010; minabs 100010 for(int i=0;i<N-1;i++) {
			minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs);
		} int i=0; int i=0; i 0 i<N-1 i N-1 N 1 i++ i++ i {
			minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs);
		} {
			minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs);
		} minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs) minabs Math.min(Math.abs(L[i]-R[i+1]),minabs) Math.min Math 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 minabs out.println(minabs) out.println out minabs private static int nextInt() {
		return Integer.parseInt(next());
	} nextInt {
		return Integer.parseInt(next());
	} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next private static long nextLong() {
		return Long.parseLong(next());
	} nextLong {
		return Long.parseLong(next());
	} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next private static String next() {
		return sc.next();
	} next {
		return sc.next();
	} return sc.next(); sc.next() sc.next sc public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int[] a = new int[N];
		for(int i=0;i<N;i++) {
			a[i]=nextInt();
		}
		sc.close();
		int[] L = new int[N];
		int[] R = new int[N];
		L[N-1] = a[N-1];
		for(int i=0;i<N-1;i++) {
			L[i]+=a[i];
			L[i+1]+=L[i];
		}
		R[0] = a[0];
		for(int i=N-1;i>0;i--) {
			R[i]+=a[i];
			R[i-1]+=R[i];
		}
		int minabs = 100010;
		for(int i=0;i<N-1;i++) {
			minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs);
		}
		out.println(minabs);
	}

	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}
} public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int[] a = new int[N];
		for(int i=0;i<N;i++) {
			a[i]=nextInt();
		}
		sc.close();
		int[] L = new int[N];
		int[] R = new int[N];
		L[N-1] = a[N-1];
		for(int i=0;i<N-1;i++) {
			L[i]+=a[i];
			L[i+1]+=L[i];
		}
		R[0] = a[0];
		for(int i=N-1;i>0;i--) {
			R[i]+=a[i];
			R[i-1]+=R[i];
		}
		int minabs = 100010;
		for(int i=0;i<N-1;i++) {
			minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs);
		}
		out.println(minabs);
	}

	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}
} Main
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int[] a = new int[N];
		for(int i=0;i<N;i++) {
			a[i]=nextInt();
		}
		sc.close();
		int[] L = new int[N];
		int[] R = new int[N];
		L[N-1] = a[N-1];
		for(int i=0;i<N-1;i++) {
			L[i]+=a[i];
			L[i+1]+=L[i];
		}
		R[0] = a[0];
		for(int i=N-1;i>0;i--) {
			R[i]+=a[i];
			R[i-1]+=R[i];
		}
		int minabs = 100010;
		for(int i=0;i<N-1;i++) {
			minabs = Math.min(Math.abs(L[i]-R[i+1]),minabs);
		}
		out.println(minabs);
	}

	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}
}
