#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  for (int t = 0; t < N; t++) {
    cin >> W.at(t);
  }
  vector<int> S(N);
  S.at(0) = W.at(0);
  for (int t = 1; t < N; t++) {
    S.at(t) = S.at(t - 1) + W.at(t);
  }
  int ans = 100000;
  for (int t = 0; t < N; t++) {
    int tmp1, tmp2;
    tmp1 = S.at(N - 1) - S.at(t);
    if (tmp1 > S.at(t)) {
      tmp2 = tmp1 - S.at(t);
    } else {
      tmp2 = S.at(t) - tmp1;
    }
    if (tmp2 < ans) {
      ans = tmp2;
    }
  }
  cout << ans << endl;
}
