#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int ans = INT_MAX;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  ans = sum;
  for (int i = 0; i < n; ++i) {
    int s = 0;
    for (int j = i; j < n; ++j) {
      s += a[j];
      int b = sum - s;
      ans = min(ans, abs(s - b));
    }
  }
  cout << ans;
}
