import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] lst = new int[n];
        int one_weigh = 0;
        int two_weigh = 0;
        int div = 0;
        for(int a=0; a<n; a++){
            lst[a] = Integer.parseInt(scan.next());
        }
        for(int a=0; a<n; a++){
            two_weigh += lst[a];
        }
        for(int a=0; a<n; a++){
            div = one_weigh - two_weigh;
            one_weigh += lst[a];
            two_weigh -= lst[a];
            if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            }
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] lst = new int[n];
        int one_weigh = 0;
        int two_weigh = 0;
        int div = 0;
        for(int a=0; a<n; a++){
            lst[a] = Integer.parseInt(scan.next());
        }
        for(int a=0; a<n; a++){
            two_weigh += lst[a];
        }
        for(int a=0; a<n; a++){
            div = one_weigh - two_weigh;
            one_weigh += lst[a];
            two_weigh -= lst[a];
            if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            }
        }
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] lst = new int[n];
        int one_weigh = 0;
        int two_weigh = 0;
        int div = 0;
        for(int a=0; a<n; a++){
            lst[a] = Integer.parseInt(scan.next());
        }
        for(int a=0; a<n; a++){
            two_weigh += lst[a];
        }
        for(int a=0; a<n; a++){
            div = one_weigh - two_weigh;
            one_weigh += lst[a];
            two_weigh -= lst[a];
            if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            }
        }
    } main {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] lst = new int[n];
        int one_weigh = 0;
        int two_weigh = 0;
        int div = 0;
        for(int a=0; a<n; a++){
            lst[a] = Integer.parseInt(scan.next());
        }
        for(int a=0; a<n; a++){
            two_weigh += lst[a];
        }
        for(int a=0; a<n; a++){
            div = one_weigh - two_weigh;
            one_weigh += lst[a];
            two_weigh -= lst[a];
            if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            }
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = Integer.parseInt(scan.next()); n Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int[] lst = new int[n]; lst new int[n] n int one_weigh = 0; one_weigh 0 int two_weigh = 0; two_weigh 0 int div = 0; div 0 for(int a=0; a<n; a++){
            lst[a] = Integer.parseInt(scan.next());
        } int a=0; int a=0; a 0 a<n a n a++ a++ a {
            lst[a] = Integer.parseInt(scan.next());
        } {
            lst[a] = Integer.parseInt(scan.next());
        } lst[a] = Integer.parseInt(scan.next()) lst[a] lst a Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan for(int a=0; a<n; a++){
            two_weigh += lst[a];
        } int a=0; int a=0; a 0 a<n a n a++ a++ a {
            two_weigh += lst[a];
        } {
            two_weigh += lst[a];
        } two_weigh += lst[a] two_weigh lst[a] lst a for(int a=0; a<n; a++){
            div = one_weigh - two_weigh;
            one_weigh += lst[a];
            two_weigh -= lst[a];
            if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            }
        } int a=0; int a=0; a 0 a<n a n a++ a++ a {
            div = one_weigh - two_weigh;
            one_weigh += lst[a];
            two_weigh -= lst[a];
            if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            }
        } {
            div = one_weigh - two_weigh;
            one_weigh += lst[a];
            two_weigh -= lst[a];
            if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            }
        } div = one_weigh - two_weigh div one_weigh - two_weigh one_weigh two_weigh one_weigh += lst[a] one_weigh lst[a] lst a two_weigh -= lst[a] two_weigh lst[a] lst a if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            } one_weigh - two_weigh==0 one_weigh - two_weigh one_weigh two_weigh 0 {
                System.out.println(0);
                break;
            } System.out.println(0) System.out.println System.out System System.out 0 break; if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            } one_weigh - two_weigh>0 one_weigh - two_weigh one_weigh two_weigh 0 {
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            } if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                } div*(-1)>one_weigh - two_weigh div*(-1) div (-1) 1 one_weigh - two_weigh one_weigh two_weigh {
                    System.out.println(one_weigh - two_weigh);
                } System.out.println(one_weigh - two_weigh) System.out.println System.out System System.out one_weigh - two_weigh one_weigh two_weigh {
                    System.out.println(div*(-1));
                } System.out.println(div*(-1)) System.out.println System.out System System.out div*(-1) div (-1) 1 break; String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] lst = new int[n];
        int one_weigh = 0;
        int two_weigh = 0;
        int div = 0;
        for(int a=0; a<n; a++){
            lst[a] = Integer.parseInt(scan.next());
        }
        for(int a=0; a<n; a++){
            two_weigh += lst[a];
        }
        for(int a=0; a<n; a++){
            div = one_weigh - two_weigh;
            one_weigh += lst[a];
            two_weigh -= lst[a];
            if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            }
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] lst = new int[n];
        int one_weigh = 0;
        int two_weigh = 0;
        int div = 0;
        for(int a=0; a<n; a++){
            lst[a] = Integer.parseInt(scan.next());
        }
        for(int a=0; a<n; a++){
            two_weigh += lst[a];
        }
        for(int a=0; a<n; a++){
            div = one_weigh - two_weigh;
            one_weigh += lst[a];
            two_weigh -= lst[a];
            if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            }
        }
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] lst = new int[n];
        int one_weigh = 0;
        int two_weigh = 0;
        int div = 0;
        for(int a=0; a<n; a++){
            lst[a] = Integer.parseInt(scan.next());
        }
        for(int a=0; a<n; a++){
            two_weigh += lst[a];
        }
        for(int a=0; a<n; a++){
            div = one_weigh - two_weigh;
            one_weigh += lst[a];
            two_weigh -= lst[a];
            if(one_weigh - two_weigh==0){
                System.out.println(0);
                break;
            }else if(one_weigh - two_weigh>0){
                if(div*(-1)>one_weigh - two_weigh){
                    System.out.println(one_weigh - two_weigh);
                }else{
                    System.out.println(div*(-1));
                }
                break;
            }
        }
    }
}