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 s[] = new int[n+1];
    s[0] = 0;
    int d[] = new int[n];
    for(int i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    for(int i=0;i<n;i++){      
      s[i+1]=w[i]+s[i];
    }
    for(int i=0;i<n;i++){
      d[i]=Math.abs((s[n]-s[i])-s[i]);
    }   
    Arrays.sort(d);
    System.out.println(d[0]);
    
  }
} 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 s[] = new int[n+1];
    s[0] = 0;
    int d[] = new int[n];
    for(int i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    for(int i=0;i<n;i++){      
      s[i+1]=w[i]+s[i];
    }
    for(int i=0;i<n;i++){
      d[i]=Math.abs((s[n]-s[i])-s[i]);
    }   
    Arrays.sort(d);
    System.out.println(d[0]);
    
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w[] = new int[n];
    int s[] = new int[n+1];
    s[0] = 0;
    int d[] = new int[n];
    for(int i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    for(int i=0;i<n;i++){      
      s[i+1]=w[i]+s[i];
    }
    for(int i=0;i<n;i++){
      d[i]=Math.abs((s[n]-s[i])-s[i]);
    }   
    Arrays.sort(d);
    System.out.println(d[0]);
    
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w[] = new int[n];
    int s[] = new int[n+1];
    s[0] = 0;
    int d[] = new int[n];
    for(int i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    for(int i=0;i<n;i++){      
      s[i+1]=w[i]+s[i];
    }
    for(int i=0;i<n;i++){
      d[i]=Math.abs((s[n]-s[i])-s[i]);
    }   
    Arrays.sort(d);
    System.out.println(d[0]);
    
  } 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 s[] = new int[n+1]; s new int[n+1] n+1 n 1 s[0] = 0 s[0] s 0 0 int d[] = new int[n]; d 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 for(int i=0;i<n;i++){      
      s[i+1]=w[i]+s[i];
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {      
      s[i+1]=w[i]+s[i];
    } {      
      s[i+1]=w[i]+s[i];
    } s[i+1]=w[i]+s[i] s[i+1] s i+1 i 1 w[i]+s[i] w[i] w i s[i] s i for(int i=0;i<n;i++){
      d[i]=Math.abs((s[n]-s[i])-s[i]);
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      d[i]=Math.abs((s[n]-s[i])-s[i]);
    } {
      d[i]=Math.abs((s[n]-s[i])-s[i]);
    } d[i]=Math.abs((s[n]-s[i])-s[i]) d[i] d i Math.abs((s[n]-s[i])-s[i]) Math.abs Math (s[n]-s[i])-s[i] (s[n]-s[i]) s[n] s n s[i] s i s[i] s i Arrays.sort(d) Arrays.sort Arrays d System.out.println(d[0]) System.out.println System.out System System.out d[0] d 0 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 s[] = new int[n+1];
    s[0] = 0;
    int d[] = new int[n];
    for(int i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    for(int i=0;i<n;i++){      
      s[i+1]=w[i]+s[i];
    }
    for(int i=0;i<n;i++){
      d[i]=Math.abs((s[n]-s[i])-s[i]);
    }   
    Arrays.sort(d);
    System.out.println(d[0]);
    
  }
} 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 s[] = new int[n+1];
    s[0] = 0;
    int d[] = new int[n];
    for(int i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    for(int i=0;i<n;i++){      
      s[i+1]=w[i]+s[i];
    }
    for(int i=0;i<n;i++){
      d[i]=Math.abs((s[n]-s[i])-s[i]);
    }   
    Arrays.sort(d);
    System.out.println(d[0]);
    
  }
} 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 s[] = new int[n+1];
    s[0] = 0;
    int d[] = new int[n];
    for(int i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    for(int i=0;i<n;i++){      
      s[i+1]=w[i]+s[i];
    }
    for(int i=0;i<n;i++){
      d[i]=Math.abs((s[n]-s[i])-s[i]);
    }   
    Arrays.sort(d);
    System.out.println(d[0]);
    
  }
}