#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int w[n + 1], sum[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
  }
  sum[1] = w[1];
  for (int i = 2; i <= n; i++) sum[i] = sum[i - 1] + w[i];
  int mindiff = INT_MAX, diff;
  for (int t = 2; t <= n; t++) {
    diff = abs(2 * sum[t - 1] - sum[n]);
    mindiff = min(diff, mindiff);
  }
  cout << mindiff << endl;
}
