import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n=sc.nextInt();

      int s1 = 0;
      int s2 = 0;
      int[] t = new int[n-1];

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

      for(int T=0;T<n-1;T++){
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      }

      int ans = t[0];
      for(int j=1;j<n-1;j++){
        if(t[j]<ans){
          ans=t[j];
        }
      }



      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 s1 = 0;
      int s2 = 0;
      int[] t = new int[n-1];

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

      for(int T=0;T<n-1;T++){
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      }

      int ans = t[0];
      for(int j=1;j<n-1;j++){
        if(t[j]<ans){
          ans=t[j];
        }
      }



      System.out.println(ans);

    }
} Main public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n=sc.nextInt();

      int s1 = 0;
      int s2 = 0;
      int[] t = new int[n-1];

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

      for(int T=0;T<n-1;T++){
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      }

      int ans = t[0];
      for(int j=1;j<n-1;j++){
        if(t[j]<ans){
          ans=t[j];
        }
      }



      System.out.println(ans);

    } main {
      Scanner sc = new Scanner(System.in);

      int n=sc.nextInt();

      int s1 = 0;
      int s2 = 0;
      int[] t = new int[n-1];

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

      for(int T=0;T<n-1;T++){
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      }

      int ans = t[0];
      for(int j=1;j<n-1;j++){
        if(t[j]<ans){
          ans=t[j];
        }
      }



      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 s1 = 0; s1 0 int s2 = 0; s2 0 int[] t = new int[n-1]; t new int[n-1] n-1 n 1 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 for(int T=0;T<n-1;T++){
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      } int T=0; int T=0; T 0 T<n-1 T n-1 n 1 T++ T++ T {
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      } {
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      } for(int j=0;j<T+1;j++){
          s1 += w[j];
        } int j=0; int j=0; j 0 j<T+1 j T+1 T 1 j++ j++ j {
          s1 += w[j];
        } {
          s1 += w[j];
        } s1 += w[j] s1 w[j] w j for(int j=T+1;j<n;j++){
          s2 += w[j];
        } int j=T+1; int j=T+1; j T+1 T 1 j<n j n j++ j++ j {
          s2 += w[j];
        } {
          s2 += w[j];
        } s2 += w[j] s2 w[j] w j t[T] = Math.abs(s1 - s2) t[T] t T Math.abs(s1 - s2) Math.abs Math s1 - s2 s1 s2 s1 = 0 s1 0 s2 = 0 s2 0 int ans = t[0]; ans t[0] t 0 for(int j=1;j<n-1;j++){
        if(t[j]<ans){
          ans=t[j];
        }
      } int j=1; int j=1; j 1 j<n-1 j n-1 n 1 j++ j++ j {
        if(t[j]<ans){
          ans=t[j];
        }
      } {
        if(t[j]<ans){
          ans=t[j];
        }
      } if(t[j]<ans){
          ans=t[j];
        } t[j]<ans t[j] t j ans {
          ans=t[j];
        } ans=t[j] ans t[j] t j 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 s1 = 0;
      int s2 = 0;
      int[] t = new int[n-1];

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

      for(int T=0;T<n-1;T++){
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      }

      int ans = t[0];
      for(int j=1;j<n-1;j++){
        if(t[j]<ans){
          ans=t[j];
        }
      }



      System.out.println(ans);

    }
} public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n=sc.nextInt();

      int s1 = 0;
      int s2 = 0;
      int[] t = new int[n-1];

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

      for(int T=0;T<n-1;T++){
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      }

      int ans = t[0];
      for(int j=1;j<n-1;j++){
        if(t[j]<ans){
          ans=t[j];
        }
      }



      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 s1 = 0;
      int s2 = 0;
      int[] t = new int[n-1];

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

      for(int T=0;T<n-1;T++){
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      }

      int ans = t[0];
      for(int j=1;j<n-1;j++){
        if(t[j]<ans){
          ans=t[j];
        }
      }



      System.out.println(ans);

    }
}
