import java.util.Scanner;
 
class Main {
    public static void main(final String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      for (int i = 0; i < n; i++) {
        w[i] = sc.nextInt();
      }
      
      int f = 0;
      int b = 0;
      int f_cnt = 0;
      int b_cnt = n - 1;
      for (int j =0; j < n; j++) {
        if (f < b) {
          f += w[f_cnt++];
        } else {
          b += w[b_cnt--];
        }
      }
      System.out.println(Math.abs(f-b));
    }
  } import java.util.Scanner; Scanner java.util class Main {
    public static void main(final String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      for (int i = 0; i < n; i++) {
        w[i] = sc.nextInt();
      }
      
      int f = 0;
      int b = 0;
      int f_cnt = 0;
      int b_cnt = n - 1;
      for (int j =0; j < n; j++) {
        if (f < b) {
          f += w[f_cnt++];
        } else {
          b += w[b_cnt--];
        }
      }
      System.out.println(Math.abs(f-b));
    }
  } Main public static void main(final String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      for (int i = 0; i < n; i++) {
        w[i] = sc.nextInt();
      }
      
      int f = 0;
      int b = 0;
      int f_cnt = 0;
      int b_cnt = n - 1;
      for (int j =0; j < n; j++) {
        if (f < b) {
          f += w[f_cnt++];
        } else {
          b += w[b_cnt--];
        }
      }
      System.out.println(Math.abs(f-b));
    } main {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      for (int i = 0; i < n; i++) {
        w[i] = sc.nextInt();
      }
      
      int f = 0;
      int b = 0;
      int f_cnt = 0;
      int b_cnt = n - 1;
      for (int j =0; j < n; j++) {
        if (f < b) {
          f += w[f_cnt++];
        } else {
          b += w[b_cnt--];
        }
      }
      System.out.println(Math.abs(f-b));
    } 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 for (int i = 0; i < n; i++) {
        w[i] = sc.nextInt();
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        w[i] = sc.nextInt();
      } {
        w[i] = sc.nextInt();
      } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc int f = 0; f 0 int b = 0; b 0 int f_cnt = 0; f_cnt 0 int b_cnt = n - 1; b_cnt n - 1 n 1 for (int j =0; j < n; j++) {
        if (f < b) {
          f += w[f_cnt++];
        } else {
          b += w[b_cnt--];
        }
      } int j =0; int j =0; j 0 j < n j n j++ j++ j {
        if (f < b) {
          f += w[f_cnt++];
        } else {
          b += w[b_cnt--];
        }
      } {
        if (f < b) {
          f += w[f_cnt++];
        } else {
          b += w[b_cnt--];
        }
      } if (f < b) {
          f += w[f_cnt++];
        } else {
          b += w[b_cnt--];
        } f < b f b {
          f += w[f_cnt++];
        } f += w[f_cnt++] f w[f_cnt++] w f_cnt++ f_cnt {
          b += w[b_cnt--];
        } b += w[b_cnt--] b w[b_cnt--] w b_cnt-- b_cnt System.out.println(Math.abs(f-b)) System.out.println System.out System System.out Math.abs(f-b) Math.abs Math f-b f b final String[] args args
import java.util.Scanner;
 
class Main {
    public static void main(final String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      for (int i = 0; i < n; i++) {
        w[i] = sc.nextInt();
      }
      
      int f = 0;
      int b = 0;
      int f_cnt = 0;
      int b_cnt = n - 1;
      for (int j =0; j < n; j++) {
        if (f < b) {
          f += w[f_cnt++];
        } else {
          b += w[b_cnt--];
        }
      }
      System.out.println(Math.abs(f-b));
    }
  }