#include <bits/stdc++.h>
using namespace std;
int d[50];
bool dp[51][1 << 24];
int main() {
  int n;
  scanf("%d", &n);
  int Max = 0;
  for (int i = 0; i < (n); i++) {
    scanf("%d", &d[i]);
  }
  dp[0][0] = true;
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (1 << 24); j++) {
      if (dp[i][j] == false) continue;
      dp[i + 1][j | 1 << d[i]] = true;
      if (j) dp[i + 1][j | 1 << (24 - d[i])] = true;
    }
  for (int i = 0; i < (1 << 24); i++) {
    if (i == 0) continue;
    if (!dp[n][i]) continue;
    vector<int> v;
    for (int j = 0; j < (24); j++) {
      if (i >> j & 1) v.push_back(j);
    }
    int sum = INT_MAX;
    for (int i = 0; i < (v.size()); i++) {
      sum = min(sum, d[i]);
      if (i < v.size() - 1) {
        int A = v[i + 1] - v[i];
        sum = min({sum, A, 24 - A});
      } else {
        int A = v.back() - v.front();
        sum = min({sum, A, 24 - A});
      }
    }
    Max = max(Max, sum);
  }
  cout << Max << endl;
}
