#include <bits/stdc++.h>
using namespace std;
template <class T>
using vec = vector<T>;
const long long inf = 1LL << 62;
const long long mod = 1e9 + 7;
const long long dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const long long dy[8] = {0, 1, 0, -1, -1, -1, 1, 1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
long long input() {
  long long tmp;
  cin >> tmp;
  return tmp;
}
string raw_input() {
  string tmp;
  cin >> tmp;
  return tmp;
}
template <class T>
void printx(T n) {
  cout << n;
}
template <class T, class U>
void printx(pair<T, U> p) {
  cout << "(" << p.first << "," << p.second << ")";
}
template <class T, class U, class V>
void printx(tuple<T, U, V> t) {
  cout << "{" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << "}"
       << endl;
}
template <class T>
void printx(vector<T> v) {
  cout << "{";
  for (long long i = 0; i < v.size(); i++) {
    printx(v[i]);
    if (i != v.size() - 1) printx(",");
  }
  cout << "}";
}
template <class T>
void print(T n) {
  printx(n);
  cout << endl;
}
template <class T>
void print(set<T> s) {
  cout << "{";
  for (auto(e) = s.begin(); (e) != s.end(); (e)++) {
    if (e != s.begin()) printx(",");
    printx(*e);
  }
  cout << "}" << endl;
}
template <class T, class U>
void print(map<T, U> mp) {
  cout << "{";
  for (auto(e) = mp.begin(); (e) != mp.end(); (e)++) {
    cout << "(" << e->first << "," << e->second << ")";
  }
  cout << "}" << endl;
}
template <class T>
void printans(vec<T> v) {
  for (long long i = 0; i < (long long)v.size(); i++) {
    cout << v[i] << (i == (long long)v.size() - 1 ? "" : " ");
  }
  cout << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
T cut(T &a, long long l, long long r) {
  return T(a.begin() + l, a.begin() + r);
}
long long n;
vec<vector<long long> > arr(2);
vector<long long> b;
void in() {
  cin >> n;
  arr[0].push_back(0);
  arr[1].push_back(0);
  for (long long i = 0; i < n; i++) {
    long long ai = input();
    long long bi = (24 - ai) % 24;
    arr[0].push_back(ai);
    arr[1].push_back(bi);
  }
}
long long dp[52][2];
long long dfs(long long i, long long p) {
  if (dp[i][p] > -1) return dp[i][p];
  if (i == n) {
    return max(abs(arr[p][i] - arr[0][i + 1]), abs(arr[p][i] - arr[1][i + 1]));
  }
  long long ans = 0;
  chmax(ans, min(abs(arr[p][i] - arr[0][i + 1]), dfs(i + 1, 0)));
  chmax(ans, min(abs(arr[p][i] - arr[1][i + 1]), dfs(i + 1, 1)));
  return dp[i][p] = ans;
}
void solve() {
  memset(dp, -1, sizeof(dp));
  print(max(dfs(0, 0), dfs(0, 1)));
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  in();
  solve();
}
