#pragma comment(linker, "/STACK:10240000")
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 110;
const int MAX_INF = 0x3fffffff;

int a[MAXN], b[MAXN];

int main ()
{
    int n;
    scanf ("%d", &n);
    for (int i = 1; i <= n; i ++)
    {
        scanf ("%d", &a[i]);
    }
    sort (a + 1, a + n + 1);
    while (a[1] == 0)
    {
        cnt ++;
        for (int i = 1; i <= n; i ++)
        {
            a[i] = a[i + 1];
        }
        n --;
    }
    if (cnt > 1)
    {
        printf ("0\n");
    }
    else
    {
        int mins = MAX_INF;
        for (int i = 2; i <= n; i ++)
        {
            int tmp = a[i] - a[i - 1];
            if (tmp < mins)
            {
                mins = tmp;
            }
        }
        int ans = mins;
        for (int i = 0; i <= n; i ++)
        {
            for (int j = 1; j <= i; j ++)
            {
                if (j % 2 == 0)
                {
                    b[j] = 1;
                }
                else
                {
                    b[j] = 0;
                }
            }
            for (int j = i + 1; j <= n; j ++)
            {
                if (j % 2 == 0)
                {
                    b[j] = 0;
                }
                else
                {
                    b[j] = 1;
                }
            }
            int last0 = 0, last1 = 0, min1, max0, mins = MAX_INF;
            bool flag0 = false, flag1 = false;
            for (int j = 1; j <= n; j ++)
            {
                if (b[j] == 0)
                {
                    if (last0 != 0)
                    {
                        int tmp = a[j] - a[last0];
                        if (tmp < mins)
                        {
                            mins = tmp;
                        }
                    }
                    last0 = j;
                    max0 = a[j];
                    flag0 = true;
                }
                else
                {
                    if (last1 != 0)
                    {
                        int tmp = a[j] - a[last1];
                        if (tmp < mins)
                        {
                            mins = tmp;
                        }
                    }
                    last1 = j;
                    min1 = 24 - a[j];
                    flag1 = true;
                }
            }
            if ((flag0) && (flag1) && (min1 - max0 < mins))
            {
                mins = min1 - max0;
            }
            if (mins > ans)
            {
                ans = mins;
            }
        }
        if (ans == MAX_INF)
        {
            ans = 0;
        }
        printf ("%d\n", ans);
    }

    return 0;
}