import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] s = sc.nextLine().split(" ");
    int[] val = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    }
    
    int ans = 100000;
    int sum2 = 0;
    for(int i = 0; i < N; i++){
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    }
    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 = Integer.parseInt(sc.nextLine());
    String[] s = sc.nextLine().split(" ");
    int[] val = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    }
    
    int ans = 100000;
    int sum2 = 0;
    for(int i = 0; i < N; i++){
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] s = sc.nextLine().split(" ");
    int[] val = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    }
    
    int ans = 100000;
    int sum2 = 0;
    for(int i = 0; i < N; i++){
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] s = sc.nextLine().split(" ");
    int[] val = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    }
    
    int ans = 100000;
    int sum2 = 0;
    for(int i = 0; i < N; i++){
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    }
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.nextLine()); N Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc String[] s = sc.nextLine().split(" "); s sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int[] val = new int[N]; val new int[N] N int sum = 0; sum 0 for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    } {
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    } val[i] = Integer.parseInt(s[i]) val[i] val i Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i sum += val[i] sum val[i] val i int ans = 100000; ans 100000 int sum2 = 0; sum2 0 for(int i = 0; i < N; i++){
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    } {
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    } sum2 += val[i] sum2 val[i] val i sum -= val[i] sum val[i] val i int a = Math.abs(sum - sum2); a Math.abs(sum - sum2) Math.abs Math sum - sum2 sum sum2 if(a < ans){
        ans = a;
      } a < ans a ans {
        ans = a;
      } ans = a ans a 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 = Integer.parseInt(sc.nextLine());
    String[] s = sc.nextLine().split(" ");
    int[] val = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    }
    
    int ans = 100000;
    int sum2 = 0;
    for(int i = 0; i < N; i++){
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] s = sc.nextLine().split(" ");
    int[] val = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    }
    
    int ans = 100000;
    int sum2 = 0;
    for(int i = 0; i < N; i++){
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    }
    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 = Integer.parseInt(sc.nextLine());
    String[] s = sc.nextLine().split(" ");
    int[] val = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(s[i]);
      sum += val[i];
    }
    
    int ans = 100000;
    int sum2 = 0;
    for(int i = 0; i < N; i++){
      sum2 += val[i];
      sum -= val[i];
      int a = Math.abs(sum - sum2);
      if(a < ans){
        ans = a;
      }
    }
    System.out.println(ans);
  }
}