import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();

        int sum = 0;
        int[] nums = new int[n];
        int min = 0;

        for (int i = 0; i < n; i++) {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        }

        min = sum;

        for (int num: nums) {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        }

        System.out.println(min);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();

        int sum = 0;
        int[] nums = new int[n];
        int min = 0;

        for (int i = 0; i < n; i++) {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        }

        min = sum;

        for (int num: nums) {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        }

        System.out.println(min);
    }
} Main public static void main(String[] args) {
        solve();
    } main {
        solve();
    } solve() solve String[] args args private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();

        int sum = 0;
        int[] nums = new int[n];
        int min = 0;

        for (int i = 0; i < n; i++) {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        }

        min = sum;

        for (int num: nums) {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        }

        System.out.println(min);
    } solve {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();

        int sum = 0;
        int[] nums = new int[n];
        int min = 0;

        for (int i = 0; i < n; i++) {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        }

        min = sum;

        for (int num: nums) {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        }

        System.out.println(min);
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) int n = input.nextInt(); n input.nextInt() input.nextInt input int sum = 0; sum 0 int[] nums = new int[n]; nums new int[n] n int min = 0; min 0 for (int i = 0; i < n; i++) {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        } {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        } nums[i] = input.nextInt() nums[i] nums i input.nextInt() input.nextInt input sum += nums[i] sum nums[i] nums i min = sum min sum for (int num: nums) {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        } int num nums {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        } {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        } sum = sum - num * 2 sum sum - num * 2 sum num * 2 num 2 if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	} sum < 0 sum 0 {
        		min = Math.min(min, sum * (-1));
        	} min = Math.min(min, sum * (-1)) min Math.min(min, sum * (-1)) Math.min Math min sum * (-1) sum (-1) 1 {
        		min = Math.min(min, sum);
        	} min = Math.min(min, sum) min Math.min(min, sum) Math.min Math min sum System.out.println(min) System.out.println System.out System System.out min public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();

        int sum = 0;
        int[] nums = new int[n];
        int min = 0;

        for (int i = 0; i < n; i++) {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        }

        min = sum;

        for (int num: nums) {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        }

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

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();

        int sum = 0;
        int[] nums = new int[n];
        int min = 0;

        for (int i = 0; i < n; i++) {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        }

        min = sum;

        for (int num: nums) {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        }

        System.out.println(min);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();

        int sum = 0;
        int[] nums = new int[n];
        int min = 0;

        for (int i = 0; i < n; i++) {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        }

        min = sum;

        for (int num: nums) {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        }

        System.out.println(min);
    }
}
