#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> country_time_differences{0};
vector<int> country_times;
int choose(int now) {
  if (now == N + 1) {
    vector<int> country_times_sorted = country_times;
    sort(country_times_sorted.begin(), country_times_sorted.end());
    int ans = 24;
    for (int i = 0; i < N; i++) {
      ans = min(ans, country_times_sorted[i + 1] - country_times_sorted[i]);
    }
    return ans;
  } else if (country_time_differences[now] % 12 == 0) {
    country_times.push_back(country_time_differences[now]);
    int ans = choose(now + 1);
    country_times.pop_back();
    return ans;
  } else {
    country_times.push_back(country_time_differences[now]);
    int ans = choose(now + 1);
    country_times.back() = 24 - country_time_differences[now];
    ans = max(ans, choose(now + 1));
    country_times.pop_back();
    return ans;
  }
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int input;
    cin >> input;
    country_time_differences.push_back(input);
  }
  if (N >= 24) {
    cout << 0 << endl;
    return 0;
  }
  cout << choose(0) << endl;
}
