#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = MOD;
  int cur = 0;
  int j = 0;
  for (int i = 0; i < n; i++) {
    while (cur + a[j] <= 180) cur += a[j], j++, j %= n;
    ans = min(ans, 2 * (180 - cur));
    cur -= a[i];
  }
  cout << ans << '\n';
  return 0;
}
