#include <bits/stdc++.h>
using namespace std;
int a[100];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[1] << endl;
    return 0;
  }
  int min1 = 1e9;
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    min1 = min(min1, abs(24 - a[i] - a[i - 1]));
  }
  cout << min1 << endl;
}
