#include <bits/stdc++.h>
using namespace std;
void read(int& x) { scanf("%d", &x); }
void read(long long& x) { scanf("%lld", &x); }
template <typename T, typename... Args>
void read(T& a, Args&... b) {
  read(a);
  read(b...);
}
int n;
vector<int> t;
int td(int first) {
  first = (first + 240) % 24;
  return min(first, 24 - first);
}
int f(int first) {
  int mt = 99;
  for (int second : t) mt = min(mt, td(first - second));
  return mt;
}
int main() {
  read(n);
  t.push_back(0);
  int first;
  read(first);
  t.push_back(first);
  for (; --n;) {
    read(first);
    if (f(first) < f(-first)) {
      t.push_back(-first);
    } else
      t.push_back(first);
  }
  n = t.size();
  int mtd = 99;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      mtd = min(mtd, td(t[j] - t[i]));
    }
  printf("%d\n", mtd);
  return 0;
}
