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];
    for(int count=0;count<n;count++){
      w[count]=sc.nextInt();
    }
  int min= 0;
  int min2=100;
    for(int t=1;t<=n;t++){
      int upn=0;
      int dun=0;
  for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    }min=upn-dun;
    if(min<0) min*=-1;
      if(min2>min) min2=min;
    }System.out.println(min2);
}
} 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];
    for(int count=0;count<n;count++){
      w[count]=sc.nextInt();
    }
  int min= 0;
  int min2=100;
    for(int t=1;t<=n;t++){
      int upn=0;
      int dun=0;
  for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    }min=upn-dun;
    if(min<0) min*=-1;
      if(min2>min) min2=min;
    }System.out.println(min2);
}
} Main public static void main(String[] args){
Scanner sc =  new Scanner(System.in);
  int n = sc.nextInt();
  int w[] =new int[n];
    for(int count=0;count<n;count++){
      w[count]=sc.nextInt();
    }
  int min= 0;
  int min2=100;
    for(int t=1;t<=n;t++){
      int upn=0;
      int dun=0;
  for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    }min=upn-dun;
    if(min<0) min*=-1;
      if(min2>min) min2=min;
    }System.out.println(min2);
} main {
Scanner sc =  new Scanner(System.in);
  int n = sc.nextInt();
  int w[] =new int[n];
    for(int count=0;count<n;count++){
      w[count]=sc.nextInt();
    }
  int min= 0;
  int min2=100;
    for(int t=1;t<=n;t++){
      int upn=0;
      int dun=0;
  for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    }min=upn-dun;
    if(min<0) min*=-1;
      if(min2>min) min2=min;
    }System.out.println(min2);
} 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 for(int count=0;count<n;count++){
      w[count]=sc.nextInt();
    } int count=0; int count=0; count 0 count<n count n count++ count++ count {
      w[count]=sc.nextInt();
    } {
      w[count]=sc.nextInt();
    } w[count]=sc.nextInt() w[count] w count sc.nextInt() sc.nextInt sc int min= 0; min 0 int min2=100; min2 100 for(int t=1;t<=n;t++){
      int upn=0;
      int dun=0;
  for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    }min=upn-dun;
    if(min<0) min*=-1;
      if(min2>min) min2=min;
    } int t=1; int t=1; t 1 t<=n t n t++ t++ t {
      int upn=0;
      int dun=0;
  for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    }min=upn-dun;
    if(min<0) min*=-1;
      if(min2>min) min2=min;
    } {
      int upn=0;
      int dun=0;
  for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    }min=upn-dun;
    if(min<0) min*=-1;
      if(min2>min) min2=min;
    } int upn=0; upn 0 int dun=0; dun 0 for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    } int count=0; int count=0; count 0 count<n count n count++ count++ count {
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    } {
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    } if((t-1)<=count) dun+=w[count];
    else upn+=w[count]; (t-1)<=count (t-1) t 1 count dun+=w[count] dun w[count] w count upn+=w[count] upn w[count] w count min=upn-dun min upn-dun upn dun if(min<0) min*=-1; min<0 min 0 min*=-1 min -1 1 if(min2>min) min2=min; min2>min min2 min min2=min min2 min System.out.println(min2) System.out.println System.out System System.out min2 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];
    for(int count=0;count<n;count++){
      w[count]=sc.nextInt();
    }
  int min= 0;
  int min2=100;
    for(int t=1;t<=n;t++){
      int upn=0;
      int dun=0;
  for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    }min=upn-dun;
    if(min<0) min*=-1;
      if(min2>min) min2=min;
    }System.out.println(min2);
}
} public class Main{
public static void main(String[] args){
Scanner sc =  new Scanner(System.in);
  int n = sc.nextInt();
  int w[] =new int[n];
    for(int count=0;count<n;count++){
      w[count]=sc.nextInt();
    }
  int min= 0;
  int min2=100;
    for(int t=1;t<=n;t++){
      int upn=0;
      int dun=0;
  for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    }min=upn-dun;
    if(min<0) min*=-1;
      if(min2>min) min2=min;
    }System.out.println(min2);
}
} 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];
    for(int count=0;count<n;count++){
      w[count]=sc.nextInt();
    }
  int min= 0;
  int min2=100;
    for(int t=1;t<=n;t++){
      int upn=0;
      int dun=0;
  for(int count=0;count<n;count++){
   if((t-1)<=count) dun+=w[count];
    else upn+=w[count];
    }min=upn-dun;
    if(min<0) min*=-1;
      if(min2>min) min2=min;
    }System.out.println(min2);
}
}