#include <bits/stdc++.h>
using namespace std;
int in() {
  int n;
  scanf("%d", &n);
  return n;
}
long long Lin() {
  long long n;
  scanf("%lld", &n);
  return n;
}
double Din() {
  double n;
  scanf("%lf", &n);
  return n;
}
long long bigmod(long long a, long long b, long long c) {
  if (b == 0) return (1LL) % c;
  long long x = bigmod(a, b / 2, c) % c;
  x = (x * x) % c;
  if (b % 2) x = (x * a) % c;
  return x;
}
const double gama = 0.57721566490;
const double eps = 0.00000001;
const long long inf = 1e17;
const long long mod = 1e9 + 7;
const int N = 2e5 + 5;
int a[380];
int main() {
  int n = in(), total = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = in();
    if (i > 1) a[i] += a[i - 1];
  }
  int ans = INT_MAX;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      int x = abs(a[j] - a[i - 1]);
      ans = min(ans, abs(360 - x - x));
    }
  }
  printf("%d\n", ans);
  return 0;
}
