#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e6 + 10;
const long long mod = 1e9 + 7;
const double PI = acos(-1);
int sum[400];
inline int ab(int x) { return x >= 0 ? x : -x; }
int main() {
  int n, x, ans = 400;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    sum[i] = sum[i - 1] + x;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      ans = min(ans, ab(360 - (sum[j] - sum[i - 1]) * 2));
    }
  }
  printf("%d\n", ans);
  return 0;
}
