#include <bits/stdc++.h>
using namespace std;
struct SCC {
  int n;
  vector<vector<int> > G, rG, T, C;
  vector<int> vector<string>, used, belong;
  SCC() {}
  SCC(int sz) : n(sz), G(sz), rG(sz), used(sz), belong(sz) {}
  void add_edge(int from, int to) {
    G[from].push_back(to);
    rG[to].push_back(from);
  }
  void input(int m, int offset = 0) {
    int a, b;
    for (int i = 0; i < m; i++) {
      cin >> a >> b;
      add_edge(a + offset, b + offset);
    }
  }
  void dfs(int v) {
    used[v] = 1;
    for (int i = 0; i < (int)G[v].size(); i++) {
      if (!used[G[v][i]]) dfs(G[v][i]);
    }
    vector<string>.push_back(v);
  }
  void rdfs(int v, int k) {
    used[v] = 1;
    belong[v] = k;
    C[k].push_back(v);
    for (int i = 0; i < (int)rG[v].size(); i++) {
      if (!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
  }
  int build() {
    fill(used.begin(), used.end(), 0);
    vector<string>.clear();
    for (int v = 0; v < n; v++) {
      if (!used[v]) dfs(v);
    }
    fill(used.begin(), used.end(), 0);
    int k = 0;
    for (int i = vector<string>.size() - 1; i >= 0; i--) {
      if (!used[vector<string>[i]]) {
        T.push_back(vector<int>());
        C.push_back(vector<int>());
        rdfs(vector<string>[i], k++);
      }
    }
    for (int i = 0; i < n; i++)
      for (int u : G[i])
        if (belong[i] != belong[u]) T[belong[i]].push_back(belong[u]);
    for (int i = 0; i < k; i++) {
      sort(T[i].begin(), T[i].end());
      T[i].erase(unique(T[i].begin(), T[i].end()), T[i].end());
    }
    return k;
  }
};
int diff(int a, int b) {
  int ret = abs(a - b);
  return min(ret, 24 - ret);
}
int main(void) {
  int i, j;
  int n;
  cin >> n;
  vector<int> a(n);
  for (i = 0; i < (n); i++) cin >> a[i];
  a.push_back(0);
  for (int ans = 12; ans >= 0; ans--) {
    SCC scc((n + 1) * 2);
    for (i = 0; i < (n); i++)
      for (j = i + 1; j < (n); j++) {
        if (diff(a[i], a[j]) < ans) {
          scc.add_edge(n - (i + 1), n - (j + 1));
          scc.add_edge(n + (j + 1), n + (i + 1));
        }
        if (diff(a[i], 24 - a[j]) < ans) {
          scc.add_edge(n - (i + 1), n + (j + 1));
          scc.add_edge(n + (j + 1), n - (i + 1));
        }
        if (diff(24 - a[i], a[j]) < ans) {
          scc.add_edge(n + (i + 1), n - (j + 1));
          scc.add_edge(n - (j + 1), n + (i + 1));
        }
        if (diff(24 - a[i], 24 - a[j]) < ans) {
          scc.add_edge(n + (i + 1), n + (j + 1));
          scc.add_edge(n - (j + 1), n - (i + 1));
        }
      }
    scc.build();
    bool c = true;
    auto belong = scc.belong;
    for (int i = 0; i < n; i++) {
      if (belong[i] == belong[n + i]) {
        c = false;
      }
    }
    if (c) {
      cout << ans << endl;
      return 0;
    }
  }
}
