import 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 ssum = 0;
        int ssum2 = 0;
        int ssumb = 0;

        for(int i=0; i<N; i++){
            W[i] = sc.nextInt();
            ssum += W[i];
        }
        for(int i=0; i<N; i++){
            if(ssum2>=ssum/2){
                break;
            }
            ssum2 += W[i];
        }
        for(int i=N-1; i>=0; i--){
            if(ssumb>=ssum/2){
                break;
            }
            ssumb += W[i];
        }
        if(ssum2<=ssumb){
            System.out.println(2*ssum2-ssum);
        }
        else if(ssumb<ssum2){
            System.out.println(2*ssumb-ssum);
        }
    }
} 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[] W = new int[N];
        int ssum = 0;
        int ssum2 = 0;
        int ssumb = 0;

        for(int i=0; i<N; i++){
            W[i] = sc.nextInt();
            ssum += W[i];
        }
        for(int i=0; i<N; i++){
            if(ssum2>=ssum/2){
                break;
            }
            ssum2 += W[i];
        }
        for(int i=N-1; i>=0; i--){
            if(ssumb>=ssum/2){
                break;
            }
            ssumb += W[i];
        }
        if(ssum2<=ssumb){
            System.out.println(2*ssum2-ssum);
        }
        else if(ssumb<ssum2){
            System.out.println(2*ssumb-ssum);
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        int ssum = 0;
        int ssum2 = 0;
        int ssumb = 0;

        for(int i=0; i<N; i++){
            W[i] = sc.nextInt();
            ssum += W[i];
        }
        for(int i=0; i<N; i++){
            if(ssum2>=ssum/2){
                break;
            }
            ssum2 += W[i];
        }
        for(int i=N-1; i>=0; i--){
            if(ssumb>=ssum/2){
                break;
            }
            ssumb += W[i];
        }
        if(ssum2<=ssumb){
            System.out.println(2*ssum2-ssum);
        }
        else if(ssumb<ssum2){
            System.out.println(2*ssumb-ssum);
        }
    } main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        int ssum = 0;
        int ssum2 = 0;
        int ssumb = 0;

        for(int i=0; i<N; i++){
            W[i] = sc.nextInt();
            ssum += W[i];
        }
        for(int i=0; i<N; i++){
            if(ssum2>=ssum/2){
                break;
            }
            ssum2 += W[i];
        }
        for(int i=N-1; i>=0; i--){
            if(ssumb>=ssum/2){
                break;
            }
            ssumb += W[i];
        }
        if(ssum2<=ssumb){
            System.out.println(2*ssum2-ssum);
        }
        else if(ssumb<ssum2){
            System.out.println(2*ssumb-ssum);
        }
    } 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 ssum = 0; ssum 0 int ssum2 = 0; ssum2 0 int ssumb = 0; ssumb 0 for(int i=0; i<N; i++){
            W[i] = sc.nextInt();
            ssum += W[i];
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            W[i] = sc.nextInt();
            ssum += W[i];
        } {
            W[i] = sc.nextInt();
            ssum += W[i];
        } W[i] = sc.nextInt() W[i] W i sc.nextInt() sc.nextInt sc ssum += W[i] ssum W[i] W i for(int i=0; i<N; i++){
            if(ssum2>=ssum/2){
                break;
            }
            ssum2 += W[i];
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            if(ssum2>=ssum/2){
                break;
            }
            ssum2 += W[i];
        } {
            if(ssum2>=ssum/2){
                break;
            }
            ssum2 += W[i];
        } if(ssum2>=ssum/2){
                break;
            } ssum2>=ssum/2 ssum2 ssum/2 ssum 2 {
                break;
            } break; ssum2 += W[i] ssum2 W[i] W i for(int i=N-1; i>=0; i--){
            if(ssumb>=ssum/2){
                break;
            }
            ssumb += W[i];
        } int i=N-1; int i=N-1; i N-1 N 1 i>=0 i 0 i-- i-- i {
            if(ssumb>=ssum/2){
                break;
            }
            ssumb += W[i];
        } {
            if(ssumb>=ssum/2){
                break;
            }
            ssumb += W[i];
        } if(ssumb>=ssum/2){
                break;
            } ssumb>=ssum/2 ssumb ssum/2 ssum 2 {
                break;
            } break; ssumb += W[i] ssumb W[i] W i if(ssum2<=ssumb){
            System.out.println(2*ssum2-ssum);
        }
        else if(ssumb<ssum2){
            System.out.println(2*ssumb-ssum);
        } ssum2<=ssumb ssum2 ssumb {
            System.out.println(2*ssum2-ssum);
        } System.out.println(2*ssum2-ssum) System.out.println System.out System System.out 2*ssum2-ssum 2*ssum2 2 ssum2 ssum if(ssumb<ssum2){
            System.out.println(2*ssumb-ssum);
        } ssumb<ssum2 ssumb ssum2 {
            System.out.println(2*ssumb-ssum);
        } System.out.println(2*ssumb-ssum) System.out.println System.out System System.out 2*ssumb-ssum 2*ssumb 2 ssumb ssum 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 ssum = 0;
        int ssum2 = 0;
        int ssumb = 0;

        for(int i=0; i<N; i++){
            W[i] = sc.nextInt();
            ssum += W[i];
        }
        for(int i=0; i<N; i++){
            if(ssum2>=ssum/2){
                break;
            }
            ssum2 += W[i];
        }
        for(int i=N-1; i>=0; i--){
            if(ssumb>=ssum/2){
                break;
            }
            ssumb += W[i];
        }
        if(ssum2<=ssumb){
            System.out.println(2*ssum2-ssum);
        }
        else if(ssumb<ssum2){
            System.out.println(2*ssumb-ssum);
        }
    }
} 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 ssum = 0;
        int ssum2 = 0;
        int ssumb = 0;

        for(int i=0; i<N; i++){
            W[i] = sc.nextInt();
            ssum += W[i];
        }
        for(int i=0; i<N; i++){
            if(ssum2>=ssum/2){
                break;
            }
            ssum2 += W[i];
        }
        for(int i=N-1; i>=0; i--){
            if(ssumb>=ssum/2){
                break;
            }
            ssumb += W[i];
        }
        if(ssum2<=ssumb){
            System.out.println(2*ssum2-ssum);
        }
        else if(ssumb<ssum2){
            System.out.println(2*ssumb-ssum);
        }
    }
} Main
import 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 ssum = 0;
        int ssum2 = 0;
        int ssumb = 0;

        for(int i=0; i<N; i++){
            W[i] = sc.nextInt();
            ssum += W[i];
        }
        for(int i=0; i<N; i++){
            if(ssum2>=ssum/2){
                break;
            }
            ssum2 += W[i];
        }
        for(int i=N-1; i>=0; i--){
            if(ssumb>=ssum/2){
                break;
            }
            ssumb += W[i];
        }
        if(ssum2<=ssumb){
            System.out.println(2*ssum2-ssum);
        }
        else if(ssumb<ssum2){
            System.out.println(2*ssumb-ssum);
        }
    }
}