#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> W[i];
    sum+=W[i];
  }
  int sumy;
  int sumz;
  for(int i=0;sumz<sum/2;i++){
    sumy=sumz;
    sumz+=W[i];
  }
  cout << min(abs(2*sumy-sum),abs(2*sumz-sum));
}