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 + 1];

    int sum = 0;
    for (int i = 1; i <= n; i++) {
      w[i] = sc.nextInt();
      sum += w[i];
    }

    int s1 = 0;
    int s2 = 0;
    int ans = sum;
    for (int i = 1; i <= n; i++) {
      s1 += w[i];
      s2 = sum - s1;
      ans = Math.min(ans, Math.abs(s2 - s1));
    }
    
    System.out.println(ans);
  }
} 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 + 1];

    int sum = 0;
    for (int i = 1; i <= n; i++) {
      w[i] = sc.nextInt();
      sum += w[i];
    }

    int s1 = 0;
    int s2 = 0;
    int ans = sum;
    for (int i = 1; i <= n; i++) {
      s1 += w[i];
      s2 = sum - s1;
      ans = Math.min(ans, Math.abs(s2 - s1));
    }
    
    System.out.println(ans);
  }
} Main public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] w = new int[n + 1];

    int sum = 0;
    for (int i = 1; i <= n; i++) {
      w[i] = sc.nextInt();
      sum += w[i];
    }

    int s1 = 0;
    int s2 = 0;
    int ans = sum;
    for (int i = 1; i <= n; i++) {
      s1 += w[i];
      s2 = sum - s1;
      ans = Math.min(ans, Math.abs(s2 - s1));
    }
    
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] w = new int[n + 1];

    int sum = 0;
    for (int i = 1; i <= n; i++) {
      w[i] = sc.nextInt();
      sum += w[i];
    }

    int s1 = 0;
    int s2 = 0;
    int ans = sum;
    for (int i = 1; i <= n; i++) {
      s1 += w[i];
      s2 = sum - s1;
      ans = Math.min(ans, Math.abs(s2 - s1));
    }
    
    System.out.println(ans);
  } 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 + 1]; w new int[n + 1] n + 1 n 1 int sum = 0; sum 0 for (int i = 1; i <= n; i++) {
      w[i] = sc.nextInt();
      sum += w[i];
    } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
      w[i] = sc.nextInt();
      sum += w[i];
    } {
      w[i] = sc.nextInt();
      sum += w[i];
    } w[i] = sc.nextInt() w[i] w i sc.nextInt() sc.nextInt sc sum += w[i] sum w[i] w i int s1 = 0; s1 0 int s2 = 0; s2 0 int ans = sum; ans sum for (int i = 1; i <= n; i++) {
      s1 += w[i];
      s2 = sum - s1;
      ans = Math.min(ans, Math.abs(s2 - s1));
    } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
      s1 += w[i];
      s2 = sum - s1;
      ans = Math.min(ans, Math.abs(s2 - s1));
    } {
      s1 += w[i];
      s2 = sum - s1;
      ans = Math.min(ans, Math.abs(s2 - s1));
    } s1 += w[i] s1 w[i] w i s2 = sum - s1 s2 sum - s1 sum s1 ans = Math.min(ans, Math.abs(s2 - s1)) ans Math.min(ans, Math.abs(s2 - s1)) Math.min Math ans Math.abs(s2 - s1) Math.abs Math s2 - s1 s2 s1 System.out.println(ans) System.out.println System.out System System.out ans 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 + 1];

    int sum = 0;
    for (int i = 1; i <= n; i++) {
      w[i] = sc.nextInt();
      sum += w[i];
    }

    int s1 = 0;
    int s2 = 0;
    int ans = sum;
    for (int i = 1; i <= n; i++) {
      s1 += w[i];
      s2 = sum - s1;
      ans = Math.min(ans, Math.abs(s2 - s1));
    }
    
    System.out.println(ans);
  }
} public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] w = new int[n + 1];

    int sum = 0;
    for (int i = 1; i <= n; i++) {
      w[i] = sc.nextInt();
      sum += w[i];
    }

    int s1 = 0;
    int s2 = 0;
    int ans = sum;
    for (int i = 1; i <= n; i++) {
      s1 += w[i];
      s2 = sum - s1;
      ans = Math.min(ans, Math.abs(s2 - s1));
    }
    
    System.out.println(ans);
  }
} 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 + 1];

    int sum = 0;
    for (int i = 1; i <= n; i++) {
      w[i] = sc.nextInt();
      sum += w[i];
    }

    int s1 = 0;
    int s2 = 0;
    int ans = sum;
    for (int i = 1; i <= n; i++) {
      s1 += w[i];
      s2 = sum - s1;
      ans = Math.min(ans, Math.abs(s2 - s1));
    }
    
    System.out.println(ans);
  }
}
