import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] w = new int[n];
    int min = 1000000;
    int total = 0;
    int current = 0;
    
    for(int i=0; i<n; i++) {
      w[i] = Integer.parseInt(str[i]);
      total += w[i];
    }

    for(int i=0; i<n; i++) {
      min = Math.min(min,Math.abs(current-total));
      total -= w[i];
      current += w[i];
    }
    System.out.println(min);
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] w = new int[n];
    int min = 1000000;
    int total = 0;
    int current = 0;
    
    for(int i=0; i<n; i++) {
      w[i] = Integer.parseInt(str[i]);
      total += w[i];
    }

    for(int i=0; i<n; i++) {
      min = Math.min(min,Math.abs(current-total));
      total -= w[i];
      current += w[i];
    }
    System.out.println(min);
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] w = new int[n];
    int min = 1000000;
    int total = 0;
    int current = 0;
    
    for(int i=0; i<n; i++) {
      w[i] = Integer.parseInt(str[i]);
      total += w[i];
    }

    for(int i=0; i<n; i++) {
      min = Math.min(min,Math.abs(current-total));
      total -= w[i];
      current += w[i];
    }
    System.out.println(min);
  } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] w = new int[n];
    int min = 1000000;
    int total = 0;
    int current = 0;
    
    for(int i=0; i<n; i++) {
      w[i] = Integer.parseInt(str[i]);
      total += w[i];
    }

    for(int i=0; i<n; i++) {
      min = Math.min(min,Math.abs(current-total));
      total -= w[i];
      current += w[i];
    }
    System.out.println(min);
  } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(in.readLine()); n Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in String[] str = in.readLine().split(" "); str in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " int[] w = new int[n]; w new int[n] n int min = 1000000; min 1000000 int total = 0; total 0 int current = 0; current 0 for(int i=0; i<n; i++) {
      w[i] = Integer.parseInt(str[i]);
      total += w[i];
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      w[i] = Integer.parseInt(str[i]);
      total += w[i];
    } {
      w[i] = Integer.parseInt(str[i]);
      total += w[i];
    } w[i] = Integer.parseInt(str[i]) w[i] w i Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i total += w[i] total w[i] w i for(int i=0; i<n; i++) {
      min = Math.min(min,Math.abs(current-total));
      total -= w[i];
      current += w[i];
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      min = Math.min(min,Math.abs(current-total));
      total -= w[i];
      current += w[i];
    } {
      min = Math.min(min,Math.abs(current-total));
      total -= w[i];
      current += w[i];
    } min = Math.min(min,Math.abs(current-total)) min Math.min(min,Math.abs(current-total)) Math.min Math min Math.abs(current-total) Math.abs Math current-total current total total -= w[i] total w[i] w i current += w[i] current w[i] w i System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] w = new int[n];
    int min = 1000000;
    int total = 0;
    int current = 0;
    
    for(int i=0; i<n; i++) {
      w[i] = Integer.parseInt(str[i]);
      total += w[i];
    }

    for(int i=0; i<n; i++) {
      min = Math.min(min,Math.abs(current-total));
      total -= w[i];
      current += w[i];
    }
    System.out.println(min);
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] w = new int[n];
    int min = 1000000;
    int total = 0;
    int current = 0;
    
    for(int i=0; i<n; i++) {
      w[i] = Integer.parseInt(str[i]);
      total += w[i];
    }

    for(int i=0; i<n; i++) {
      min = Math.min(min,Math.abs(current-total));
      total -= w[i];
      current += w[i];
    }
    System.out.println(min);
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] w = new int[n];
    int min = 1000000;
    int total = 0;
    int current = 0;
    
    for(int i=0; i<n; i++) {
      w[i] = Integer.parseInt(str[i]);
      total += w[i];
    }

    for(int i=0; i<n; i++) {
      min = Math.min(min,Math.abs(current-total));
      total -= w[i];
      current += w[i];
    }
    System.out.println(min);
  }
}