import java.util.*;

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


        int sum2 = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i) {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        }
        System.out.println(min);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] lis = new int[n];
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
            sum += lis[i];
        }


        int sum2 = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i) {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        }
        System.out.println(min);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] lis = new int[n];
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
            sum += lis[i];
        }


        int sum2 = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i) {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        }
        System.out.println(min);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] lis = new int[n];
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
            sum += lis[i];
        }


        int sum2 = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i) {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        }
        System.out.println(min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] lis = new int[n]; lis new int[n] n int sum = 0; sum 0 for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
            sum += lis[i];
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            lis[i] = sc.nextInt();
            sum += lis[i];
        } {
            lis[i] = sc.nextInt();
            sum += lis[i];
        } lis[i] = sc.nextInt() lis[i] lis i sc.nextInt() sc.nextInt sc sum += lis[i] sum lis[i] lis i int sum2 = 0; sum2 0 int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < n; ++i) {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        } {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        } sum -= lis[i] sum lis[i] lis i sum2 += lis[i] sum2 lis[i] lis i min = Math.min(min, Math.abs(sum - sum2)) min Math.min(min, Math.abs(sum - sum2)) Math.min Math min Math.abs(sum - sum2) Math.abs Math sum - sum2 sum sum2 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 sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] lis = new int[n];
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
            sum += lis[i];
        }


        int sum2 = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i) {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        }
        System.out.println(min);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] lis = new int[n];
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
            sum += lis[i];
        }


        int sum2 = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i) {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        }
        System.out.println(min);
    }
} Main
import java.util.*;

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


        int sum2 = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i) {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        }
        System.out.println(min);
    }
}
