#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)

int cnt[13] = {};
int place[24];

int Ans() {
  int i = 0, f = 1;

  if (cnt[0] == 0) {
    place[i++] = 0;
  } else {
    return 0;
  }

  FOR(di, 1, 12) {
    if (cnt[di] == 0) {
      continue;
    } else if (cnt[di] == 1) {
      if (f) {
        place[i++] = di;
        f = 0;
      } else {
        place[i++] = 24 - di;
        f = 1;
      }
    } else if (cnt[di] == 2) {
      place[i++] = di;
      place[i++] = 24 - di;
    } else {
      return 0;
    }
  }

  if (cnt[12] == 0) {
    // do nothing
  } else if (cnt[12] == 1) {
    place[i++] = 12;
  } else {
    return 0;
  }

  int ans = 12;
  sort(place, place+i);
  REP(j, i-1) { ans = min(ans, place[j+1] - place[j]); }
  ans = min(ans, 24 - place[i-1]);
  return ans;
}

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    int tmp;
    cin >> tmp;
    cnt[tmp]++;
  }

  cout << Ans() << endl;

  return 0;
}
