#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> d(13, 0);
  ++d[0];
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    ++d[a];
  }
  int ans = 12;
  for (int i = 0; i <= 12; ++i) {
    if (d[i] > 2) ans = 0;
    if (d[i] == 0) continue;
    for (int j = 0; j <= 12; ++j) {
      if (i == j) {
        if (d[i] == 2) ans = min(ans, min(2 * i, 24 - 2 * i));
      } else if (d[j] == 0)
        continue;
      else if (d[i] == 2 || d[j] == 2)
        ans = min(ans, abs(i - j));
      else
        ans = min(ans, min(i + j, 24 - i - j));
    }
  }
  cout << ans << endl;
  return 0;
}
