import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum1 = 0, sum2 = 0, min = 0;
        
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum1 += w[i];
        }

        min = sum1;
for (int i = 0; i < n; i++) {
    sum1 -= w[i];
    sum2 += w[i];
        if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        }
    }
        System.out.println(min);
        

		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum1 = 0, sum2 = 0, min = 0;
        
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum1 += w[i];
        }

        min = sum1;
for (int i = 0; i < n; i++) {
    sum1 -= w[i];
    sum2 += w[i];
        if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        }
    }
        System.out.println(min);
        

		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum1 = 0, sum2 = 0, min = 0;
        
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum1 += w[i];
        }

        min = sum1;
for (int i = 0; i < n; i++) {
    sum1 -= w[i];
    sum2 += w[i];
        if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        }
    }
        System.out.println(min);
        

		sc.close();
	} main {
		Scanner sc = new Scanner((System.in));
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum1 = 0, sum2 = 0, min = 0;
        
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum1 += w[i];
        }

        min = sum1;
for (int i = 0; i < n; i++) {
    sum1 -= w[i];
    sum2 += w[i];
        if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        }
    }
        System.out.println(min);
        

		sc.close();
	} 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 int sum1 = 0 sum1 0 sum2 = 0 sum2 0 min = 0; min 0 for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum1 += w[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            w[i] = sc.nextInt();
            sum1 += w[i];
        } {
            w[i] = sc.nextInt();
            sum1 += w[i];
        } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc sum1 += w[i] sum1 w[i] w i min = sum1 min sum1 for (int i = 0; i < n; i++) {
    sum1 -= w[i];
    sum2 += w[i];
        if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
    sum1 -= w[i];
    sum2 += w[i];
        if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        }
    } {
    sum1 -= w[i];
    sum2 += w[i];
        if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        }
    } sum1 -= w[i] sum1 w[i] w i sum2 += w[i] sum2 w[i] w i if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        } Math.abs(sum1 - sum2) < min Math.abs(sum1 - sum2) Math.abs Math sum1 - sum2 sum1 sum2 min {
            min = Math.abs(sum1 - sum2);
        } min = Math.abs(sum1 - sum2) min Math.abs(sum1 - sum2) Math.abs Math sum1 - sum2 sum1 sum2 System.out.println(min) System.out.println System.out System System.out min sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum1 = 0, sum2 = 0, min = 0;
        
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum1 += w[i];
        }

        min = sum1;
for (int i = 0; i < n; i++) {
    sum1 -= w[i];
    sum2 += w[i];
        if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        }
    }
        System.out.println(min);
        

		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum1 = 0, sum2 = 0, min = 0;
        
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum1 += w[i];
        }

        min = sum1;
for (int i = 0; i < n; i++) {
    sum1 -= w[i];
    sum2 += w[i];
        if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        }
    }
        System.out.println(min);
        

		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum1 = 0, sum2 = 0, min = 0;
        
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum1 += w[i];
        }

        min = sum1;
for (int i = 0; i < n; i++) {
    sum1 -= w[i];
    sum2 += w[i];
        if (Math.abs(sum1 - sum2) < min) {
            min = Math.abs(sum1 - sum2);
        }
    }
        System.out.println(min);
        

		sc.close();
	}
}
