import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sumleft = 0;
    int sumright = 0;
    int array[] = new int[N];
    for (int i=0;i<N;i++){
     int W = sc.nextInt();
     sumright += W;
     array[i] = W;
    }
    int ans = Math.abs(sumright-sumleft);
    for (int j=0;j<N;j++){
      sumleft += array[j];
      sumright -= array[j];
      ans = Math.min(ans, Math.abs(sumright-sumleft));
    }
    System.out.println(ans);
  }
}
   import java.util.*; util.* java class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sumleft = 0;
    int sumright = 0;
    int array[] = new int[N];
    for (int i=0;i<N;i++){
     int W = sc.nextInt();
     sumright += W;
     array[i] = W;
    }
    int ans = Math.abs(sumright-sumleft);
    for (int j=0;j<N;j++){
      sumleft += array[j];
      sumright -= array[j];
      ans = Math.min(ans, Math.abs(sumright-sumleft));
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sumleft = 0;
    int sumright = 0;
    int array[] = new int[N];
    for (int i=0;i<N;i++){
     int W = sc.nextInt();
     sumright += W;
     array[i] = W;
    }
    int ans = Math.abs(sumright-sumleft);
    for (int j=0;j<N;j++){
      sumleft += array[j];
      sumright -= array[j];
      ans = Math.min(ans, Math.abs(sumright-sumleft));
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sumleft = 0;
    int sumright = 0;
    int array[] = new int[N];
    for (int i=0;i<N;i++){
     int W = sc.nextInt();
     sumright += W;
     array[i] = W;
    }
    int ans = Math.abs(sumright-sumleft);
    for (int j=0;j<N;j++){
      sumleft += array[j];
      sumright -= array[j];
      ans = Math.min(ans, Math.abs(sumright-sumleft));
    }
    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 sumleft = 0; sumleft 0 int sumright = 0; sumright 0 int array[] = new int[N]; array new int[N] N for (int i=0;i<N;i++){
     int W = sc.nextInt();
     sumright += W;
     array[i] = W;
    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
     int W = sc.nextInt();
     sumright += W;
     array[i] = W;
    } {
     int W = sc.nextInt();
     sumright += W;
     array[i] = W;
    } int W = sc.nextInt(); W sc.nextInt() sc.nextInt sc sumright += W sumright W array[i] = W array[i] array i W int ans = Math.abs(sumright-sumleft); ans Math.abs(sumright-sumleft) Math.abs Math sumright-sumleft sumright sumleft for (int j=0;j<N;j++){
      sumleft += array[j];
      sumright -= array[j];
      ans = Math.min(ans, Math.abs(sumright-sumleft));
    } int j=0; int j=0; j 0 j<N j N j++ j++ j {
      sumleft += array[j];
      sumright -= array[j];
      ans = Math.min(ans, Math.abs(sumright-sumleft));
    } {
      sumleft += array[j];
      sumright -= array[j];
      ans = Math.min(ans, Math.abs(sumright-sumleft));
    } sumleft += array[j] sumleft array[j] array j sumright -= array[j] sumright array[j] array j ans = Math.min(ans, Math.abs(sumright-sumleft)) ans Math.min(ans, Math.abs(sumright-sumleft)) Math.min Math ans Math.abs(sumright-sumleft) Math.abs Math sumright-sumleft sumright sumleft System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sumleft = 0;
    int sumright = 0;
    int array[] = new int[N];
    for (int i=0;i<N;i++){
     int W = sc.nextInt();
     sumright += W;
     array[i] = W;
    }
    int ans = Math.abs(sumright-sumleft);
    for (int j=0;j<N;j++){
      sumleft += array[j];
      sumright -= array[j];
      ans = Math.min(ans, Math.abs(sumright-sumleft));
    }
    System.out.println(ans);
  }
}
  