import java.util.*;

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

    int n = sc.nextInt();

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

    int result = 100;
    for (int i = 0; i < n; i++) {
      int t = i;

      int left = 0;
      int right = 0;
      for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      }

      int abs = Math.abs(left - right);

      if(abs < result) {
        result = abs;
      }
    }

    System.out.println(result);
  }
} 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[] list = new int[n];
    for (int i = 0; i < n; i++) {
      list[i] = sc.nextInt();
    }

    int result = 100;
    for (int i = 0; i < n; i++) {
      int t = i;

      int left = 0;
      int right = 0;
      for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      }

      int abs = Math.abs(left - right);

      if(abs < result) {
        result = abs;
      }
    }

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

    int n = sc.nextInt();

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

    int result = 100;
    for (int i = 0; i < n; i++) {
      int t = i;

      int left = 0;
      int right = 0;
      for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      }

      int abs = Math.abs(left - right);

      if(abs < result) {
        result = abs;
      }
    }

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

    int n = sc.nextInt();

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

    int result = 100;
    for (int i = 0; i < n; i++) {
      int t = i;

      int left = 0;
      int right = 0;
      for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      }

      int abs = Math.abs(left - right);

      if(abs < result) {
        result = abs;
      }
    }

    System.out.println(result);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] list = new int[n]; list new int[n] n for (int i = 0; i < n; i++) {
      list[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      list[i] = sc.nextInt();
    } {
      list[i] = sc.nextInt();
    } list[i] = sc.nextInt() list[i] list i sc.nextInt() sc.nextInt sc int result = 100; result 100 for (int i = 0; i < n; i++) {
      int t = i;

      int left = 0;
      int right = 0;
      for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      }

      int abs = Math.abs(left - right);

      if(abs < result) {
        result = abs;
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      int t = i;

      int left = 0;
      int right = 0;
      for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      }

      int abs = Math.abs(left - right);

      if(abs < result) {
        result = abs;
      }
    } {
      int t = i;

      int left = 0;
      int right = 0;
      for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      }

      int abs = Math.abs(left - right);

      if(abs < result) {
        result = abs;
      }
    } int t = i; t i int left = 0; left 0 int right = 0; right 0 for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      } {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      } if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        } t >= j t j {
          left += list[j];
        } left += list[j] left list[j] list j if (t < j) {
          right += list[j];
        } t < j t j {
          right += list[j];
        } right += list[j] right list[j] list j int abs = Math.abs(left - right); abs Math.abs(left - right) Math.abs Math left - right left right if(abs < result) {
        result = abs;
      } abs < result abs result {
        result = abs;
      } result = abs result abs System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

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

    int result = 100;
    for (int i = 0; i < n; i++) {
      int t = i;

      int left = 0;
      int right = 0;
      for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      }

      int abs = Math.abs(left - right);

      if(abs < result) {
        result = abs;
      }
    }

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

    int n = sc.nextInt();

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

    int result = 100;
    for (int i = 0; i < n; i++) {
      int t = i;

      int left = 0;
      int right = 0;
      for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      }

      int abs = Math.abs(left - right);

      if(abs < result) {
        result = abs;
      }
    }

    System.out.println(result);
  }
} Main
import java.util.*;

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

    int n = sc.nextInt();

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

    int result = 100;
    for (int i = 0; i < n; i++) {
      int t = i;

      int left = 0;
      int right = 0;
      for (int j = 0; j < n; j++) {
        if(t >= j) {
          left += list[j];
        } else if (t < j) {
          right += list[j];
        }
      }

      int abs = Math.abs(left - right);

      if(abs < result) {
        result = abs;
      }
    }

    System.out.println(result);
  }
}
