#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  int a[13] = {0};
  a[0]++;
  for (int i = 0; i < N; i++) {
    int D;
    cin >> D;
    a[D]++;
  }
  int diff[25][25];
  for (int i = 0; i <= 24; i++) {
    for (int j = 0; j <= 24; j++) {
      diff[i][j] = min(abs(i - j), 24 - abs(i - j));
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << 12); i++) {
    int d = INT_MAX;
    for (int j = 0; j <= 12; j++) {
      for (int k = j + 1; k <= 12; k++) {
        if (!a[j] || !a[k]) {
          continue;
        }
        if (a[j] > 2 || a[k] > 2) {
          cout << 0 << endl;
          return 0;
        }
        int x = j, y = k;
        if (a[j] == 1 && a[k] == 1) {
          if (1 << j & i) {
            x = 24 - j;
          }
          if (1 << k & i) {
            y = 24 - k;
          }
          d = min(d, diff[x][y]);
        } else if (a[j] == 1) {
          if (1 << j & i) {
            x = 24 - j;
          }
          d = min(min(d, diff[x][k]), min(diff[x][24 - k], diff[k][24 - k]));
        } else if (a[k] == 1) {
          if (1 << k & i) {
            x = 24 - k;
          }
          d = min(min(d, diff[x][j]), min(diff[x][24 - j], diff[j][24 - j]));
        } else {
          d = min(d, min(min(diff[j][k], diff[24 - j][k]),
                         min(diff[j][24 - k], diff[24 - j][24 - k])));
        }
      }
    }
    if (d == INT_MAX) {
      d = 0;
    }
    ans = max(ans, d);
  }
  cout << ans << endl;
  return 0;
}
