#include <bits/stdc++.h>
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
using namespace std;
long long max(long long a, int b) { return max(a, long long(b)); }
long long max(int a, long long b) { return max(long long(a), b); }
long long min(long long a, int b) { return min(a, long long(b)); }
long long min(int a, long long b) { return min(long long(a), b); }
struct Scc {
  int n;
  vector<vector<int>> g, rg;
  vector<int> cmp, visited, num;
  Scc(int N) {
    n = N;
    cmp.resize(n);
    visited.resize(n);
    g.resize(n);
    rg.resize(n);
  }
  void add_edge(int from, int to) {
    g[from].push_back(to);
    rg[to].push_back(from);
  }
  void dfs(int v) {
    visited[v] = true;
    for (int i = 0; i < g[v].size(); ++i) {
      if (!visited[g[v][i]]) dfs(g[v][i]);
    }
    num.push_back(v);
  }
  void rdfs(int v, int k) {
    visited[v] = true;
    cmp[v] = k;
    for (int i = 0; i < rg[v].size(); ++i) {
      if (!visited[rg[v][i]]) rdfs(rg[v][i], k);
    }
  }
  int calc() {
    for (int i = 0; i < n; ++i) visited[i] = false;
    num.clear();
    for (int i = 0; i < n; ++i) {
      if (!visited[i]) dfs(i);
    }
    for (int i = 0; i < n; ++i) visited[i] = false;
    int k = 0;
    for (int i = num.size() - 1; i >= 0; --i) {
      if (!visited[num[i]]) {
        rdfs(num[i], k);
        ++k;
      }
    }
    return k;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> d(n);
  for (long long i = 0; i < long long(n); ++i) cin >> d[i];
  int mint = 1000000001ll;
  for (long long i = 0; i < long long(n); ++i) {
    mint = min(min(d[i], 24 - d[i]), mint);
  }
  for (long long t = long long(mint + 1) - 1; t >= 0; --t) {
    Scc scc(2 * n);
    int f = 1;
    for (long long i = 0; i < long long(n); ++i) {
      for (long long j = i + 1; j < long long(n); ++j) {
        if (abs(d[i] - d[j]) < t) {
          if (abs(d[i] + d[j] - 24) < t) {
            goto next;
          } else {
            scc.add_edge(i, n + j);
            scc.add_edge(j, n + i);
          }
        }
        if (abs(d[i] + d[j] - 24) < t) {
          scc.add_edge(i, j);
          scc.add_edge(j, i);
        }
      }
    }
    scc.calc();
    for (long long i = 0; i < long long(n); ++i) {
      if (scc.cmp[i] == scc.cmp[n + i]) f = 0;
    }
    if (f) {
      cout << t << endl;
      return 0;
    }
  next:;
  }
}
