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