using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private int[] D;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            D = sc.IntArray();
        }

        public void Solve()
        {
            Scan();
            var cnt = new int[13];
            foreach (var i in D)
            {
                cnt[i]++;
            }

            if (cnt[0] > 0)
            {
                Console.WriteLine(0);
                return;
            }

            if (cnt[12] >= 2)
            {
                Console.WriteLine(0);
            }

            int c = 0;
            foreach (var i in cnt)
            {
                if (i == 1) c++;
                if (i >= 3)
                {
                    Console.WriteLine(0);
                    return;
                }
            }

            int loop = 1 << c;
            int ans = 0;

            for (int i = 0; i < loop; i++)
            {
                int cp = i;
                bool[] b = new bool[24];
                b[11] = true;
                if (cnt[12] > 0)
                {
                    b[23] = true;
                }
                for (int j = 1; j <= 11; j++)
                {
                    if (cnt[j] == 2)
                    {
                        b[11 + j] = true;
                        b[11 - j] = true;
                    }
                    else if (cnt[j] == 1)
                    {
                        if (cp % 2 == 0)
                        {
                            b[11 + j] = true;
                        }
                        else
                        {
                            b[11 - j] = true;
                        }

                        cp /= 2;
                    }
                }

                int min = 12;
                int before;
                for (before = 23; before >= 0; before--)
                {
                    if (b[before])
                    {

                        break;
                    }
                }

                before -= 24;
                for (int j = 0; j < 24; j++)
                {
                    if (b[j])
                    {
                        min = Math.Min(min, j - before);
                        before = j;

                    }
                }

                ans = Math.Max(ans, min);
            }
            Console.WriteLine(ans);
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13140