import java.io.*;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int N = Integer.parseInt(br.readLine());
        int[] arr = new int[N];
        int s1=0,s2=0;
        int ans=Integer.MAX_VALUE;
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=0;i<N;++i)
        {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        }
        for(int i=0;i<N;++i)
        {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        }
        bw.write(ans+"");
        bw.close();
    }

} import java.io.*; io.* java import java.util.StringTokenizer; StringTokenizer java.util public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int N = Integer.parseInt(br.readLine());
        int[] arr = new int[N];
        int s1=0,s2=0;
        int ans=Integer.MAX_VALUE;
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=0;i<N;++i)
        {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        }
        for(int i=0;i<N;++i)
        {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        }
        bw.write(ans+"");
        bw.close();
    }

} Main public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int N = Integer.parseInt(br.readLine());
        int[] arr = new int[N];
        int s1=0,s2=0;
        int ans=Integer.MAX_VALUE;
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=0;i<N;++i)
        {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        }
        for(int i=0;i<N;++i)
        {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        }
        bw.write(ans+"");
        bw.close();
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int N = Integer.parseInt(br.readLine());
        int[] arr = new int[N];
        int s1=0,s2=0;
        int ans=Integer.MAX_VALUE;
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=0;i<N;++i)
        {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        }
        for(int i=0;i<N;++i)
        {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        }
        bw.write(ans+"");
        bw.close();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); bw new BufferedWriter(new OutputStreamWriter(System.out)) int N = Integer.parseInt(br.readLine()); N Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int[] arr = new int[N]; arr new int[N] N int s1=0 s1 0 s2=0; s2 0 int ans=Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) for(int i=0;i<N;++i)
        {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        } int i=0; int i=0; i 0 i<N i N ++i ++i i {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        } {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        } arr[i] = Integer.parseInt(st.nextToken()) arr[i] arr i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st s2+=arr[i] s2 arr[i] arr i for(int i=0;i<N;++i)
        {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        } int i=0; int i=0; i 0 i<N i N ++i ++i i {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        } {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        } s1+=arr[i] s1 arr[i] arr i s2-=arr[i] s2 arr[i] arr i ans = Math.min(ans, Math.abs(s1-s2)) ans Math.min(ans, Math.abs(s1-s2)) Math.min Math ans Math.abs(s1-s2) Math.abs Math s1-s2 s1 s2 bw.write(ans+"") bw.write bw ans+"" ans "" bw.close() bw.close bw String[] args args public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int N = Integer.parseInt(br.readLine());
        int[] arr = new int[N];
        int s1=0,s2=0;
        int ans=Integer.MAX_VALUE;
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=0;i<N;++i)
        {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        }
        for(int i=0;i<N;++i)
        {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        }
        bw.write(ans+"");
        bw.close();
    }

} public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int N = Integer.parseInt(br.readLine());
        int[] arr = new int[N];
        int s1=0,s2=0;
        int ans=Integer.MAX_VALUE;
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=0;i<N;++i)
        {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        }
        for(int i=0;i<N;++i)
        {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        }
        bw.write(ans+"");
        bw.close();
    }

} Main
import java.io.*;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int N = Integer.parseInt(br.readLine());
        int[] arr = new int[N];
        int s1=0,s2=0;
        int ans=Integer.MAX_VALUE;
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=0;i<N;++i)
        {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        }
        for(int i=0;i<N;++i)
        {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        }
        bw.write(ans+"");
        bw.close();
    }

}
