#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1], b[n];
  b[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i] + b[i - 1];
  }
  if (n == 1) {
    cout << 360;
    return 0;
  }
  int ans = 1000;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (fabs(360 - 2 * (b[j] - b[i - 1])) < ans)
        ans = fabs(360 - 2 * (b[j] - b[i - 1]));
    }
  }
  cout << ans;
  return 0;
}
