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