#include <bits/stdc++.h>
using namespace std;
long long readi() {
  long long input = 0;
  char c = ' ';
  while (c < '-') {
    c = getchar();
  }
  bool negative = false;
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  while (c >= '0') {
    input = 10 * input + (c - '0');
    c = getchar();
  }
  if (negative) {
    input = -input;
  }
  return input;
}
void printi(long long output) {
  if (output == 0) {
    putchar('0');
    return;
  }
  if (output < 0) {
    putchar('-');
    output = -output;
  }
  int aout[20];
  int ilen = 0;
  while (output) {
    aout[ilen] = ((output % 10));
    output /= 10;
    ilen++;
  }
  for (int i = ilen - 1; i >= 0; i--) {
    putchar(aout[i] + '0');
  }
  return;
}
string reads() {
  string input = "";
  char c = ' ';
  while (c <= ' ') {
    c = getchar();
  }
  while (c > ' ') {
    input += c;
    c = getchar();
  }
  return input;
}
int sgn(long long x) {
  if (x < 0) {
    return -1;
  }
  if (x > 0) {
    return 1;
  }
  return 0;
}
long long randomize(long long x) {
  return (((1ll << 31) * rand()) + rand()) % x;
}
const long double PI = 4.0 * atan(1.0);
const long double EPS = 0.000000000000001;
long long normalize(long long x) {
  return (((x % 1000000007) + 1000000007) % 1000000007);
}
int N;
int arr[80];
int cnt[80];
int ans = 0;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  srand(time(0));
  if (fopen("acf17c.in", "r")) {
    freopen("acf17c.in", "r", stdin);
    freopen("acf17c.out", "w", stdout);
  }
  cin >> N;
  if (N >= 24) {
    cout << "0\n";
    return 0;
  }
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
    if (arr[i] == 0) {
      cout << "0\n";
      return 0;
    }
  }
  for (int i = 0; i < (1 << N); i++) {
    for (int j = 0; j < 24; j++) {
      cnt[j] = 0;
    }
    cnt[0]++;
    for (int j = 0; j < N; j++) {
      if (i & (1 << j)) {
        cnt[24 - arr[j]]++;
      } else {
        cnt[arr[j]]++;
      }
    }
    int cur = 1000000007;
    for (int j = 0; j < 24; j++) {
      if (cnt[j] >= 2) {
        cur = 0;
        break;
      }
    }
    if (cur == 0) {
      continue;
    }
    for (int j = 0; j < 24; j++) {
      for (int k = j + 1; k < 24; k++) {
        if (cnt[j] && cnt[k]) {
          cur = min(cur, min(k - j, 24 - j + k));
        }
      }
    }
    ans = max(ans, cur);
  }
  cout << ans << '\n';
  return 0;
}
