#include <bits/stdc++.h>
int main() {
  int N;
  scanf("%d", &N);
  int W[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &W[i]);
  }
  int min = 10000;
  int s1, s2, abs;
  for (int T = 1; T < N; T++) {
    s1 = 0;
    s2 = 0;
    for (int i = 0; i < T; i++) {
      s1 += W[i];
    }
    for (int i = T; i < N; i++) {
      s2 += W[i];
    }
    if (s1 < s2) {
      abs = s2 - s1;
    } else {
      abs = s1 - s2;
    }
    if (min > abs) {
      min = abs;
    }
  }
  printf("%d", min);
  return 0;
}
