In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.

Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example.

Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours.

Find the maximum possible value of s.

Constraints

* 1 \leq N \leq 50
* 0 \leq D_i \leq 12
* All input values are integers.

Input

Input is given from Standard Input in the following format:


N
D_1 D_2 ... D_N


Output

Print the maximum possible value of s.

Examples

Input

3
7 12 8


Output

4


Input

2
11 11


Output

2


Input

1
0


Output

0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TimeGap solver = new TimeGap();
        solver.solve(1, in, out);
        out.close();
    }

    static class TimeGap {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int[] D = new int[N + 1];
            int[] cnt = new int[13];
            cnt[0] = 1;
            for (int i = 1; i <= N; i++) {
                D[i] = in.nextInt();
                cnt[D[i]]++;
            }
            if (cnt[0] >= 2 || cnt[12] >= 2) {
                out.println(0);
                return;
            }

            for (int i = 1; i <= 11; i++) {
                if (cnt[i] > 2) {
                    out.println(0);
                    return;
                }
            }

            out.println(find(0, 0, cnt, new int[N + 1]));
        }

        private int find(int idx, int candIdx, int[] cnt, int[] cand) {
            if (idx == 13) {
                return findMinGap(cand.clone());
            }

            if (cnt[idx] == 0) return find(idx + 1, candIdx, cnt, cand);

            if (idx == 0 || idx == 12) {
                cand[candIdx] = idx;
                return find(idx + 1, candIdx + 1, cnt, cand);
            }
            if (cnt[idx] == 1) {
                cand[candIdx] = idx;
                int a1 = find(idx + 1, candIdx + 1, cnt, cand);
                cand[candIdx] = 24 - idx;
                int a2 = find(idx + 1, candIdx + 1, cnt, cand);
                return Math.max(a1, a2);
            }
            cand[candIdx] = idx;
            cand[candIdx + 1] = 24 - idx;

            return find(idx + 1, candIdx + 2, cnt, cand);
        }

        private int findMinGap(int[] arr) {
            int N = arr.length;
            int ans = Integer.MAX_VALUE;
            Arrays.sort(arr);
            for (int i = 1; i < N; i++) {
                ans = Math.min(ans, Math.abs(arr[i] - arr[i - 1]));
            }
            ans = Math.min(ans, 24 - arr[N - 1]);
            return ans;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

