#include <bits/stdc++.h>
using namespace std;
int a[361], i, j, m = 360, n, k = 0;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> k;
    a[i] = a[i - 1] + k;
  }
  for (i = 0; i < n; i++)
    for (j = i; j < n; j++) m = min(abs(2 * (abs(a[i] - a[j])) - 360), m);
  cout << abs(m) << endl;
}
