A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.

The students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.

However, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. 

After all the swaps each compartment should either have no student left, or have a company of three or four students. 

Input

The first line contains integer n (1 ≤ n ≤ 106) — the number of compartments in the carriage. The second line contains n integers a1, a2, ..., an showing how many students ride in each compartment (0 ≤ ai ≤ 4). It is guaranteed that at least one student is riding in the train.

Output

If no sequence of swapping seats with other people leads to the desired result, print number "-1" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.

Examples

Input

5
1 2 2 4 3


Output

2


Input

3
4 1 1


Output

2


Input

4
0 3 0 4


Output

0
/**
 * @author cplayer on 2018/6/23.
 * @version 1.0
 */

import java.util.*;
import java.util.stream.IntStream;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) {
        try {
            InputReader in;
            PrintWriter out;
            boolean useOutput = false;
            if (System.getProperty("ONLINE_JUDGE") == null) useOutput = true;
            if (useOutput) {
                FileInputStream fin = new FileInputStream(new File("src/data.in"));
                in = new InputReader(fin);
                FileOutputStream fout = new FileOutputStream(new File("src/data.out"));
                out = new PrintWriter(fout);
            } else {
                InputStream inputStream = System.in;
                in = new InputReader(inputStream);
                OutputStream outputStream = System.out;
                out = new PrintWriter(outputStream);
            }
            Solver solver = new Solver();
            solver.solve(in, out);
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static class Solver {

        public void solve (InputReader cin, PrintWriter cout) {
            try {
                int n = cin.nextInt();
                int num[] = new int[5];
                Arrays.fill(num, 0);
                for (int i = 0; i < n; ++i) {
                    int tmp = cin.nextInt();
                    num[tmp]++;
                }
                int snum[] = new int[n + 2];
                Arrays.fill(snum, 0);
                for (int i = 1, pt = 0; pt < 5; ++pt) {
                    while (num[pt] > 0) {
                        num[pt]--;
                        snum[i] = pt;
                        i++;
                    }
                }
                int target[] = new int[n + 2], free[] = new int[n + 2], extra[] = new int[n + 2];
                target[n + 1] = 0; free[n + 1] = 0; extra[n + 1] = 0;
                for (int i = n; i > 0; --i) {
                    target[i] = target[i + 1] + (snum[i] < 3 ? 3 - snum[i] : 0);
                    free[i] = free[i + 1] + (4 - snum[i]);
                    extra[i] = extra[i + 1] + (snum[i] == 4 ? 1 : 0);
                }
                for (int i = 1; i <= n; ++i) {
                    snum[i] += snum[i - 1];
                }
                int res = Integer.MAX_VALUE;
                // 左半边可以为0，但是右半边必然不可以
                for (int i = 0; i < n; ++i) {
                    int source = snum[i];
                    int rtarget = target[i + 1];
                    int rfree = free[i + 1];
                    int rextra = extra[i + 1];
                    if (source <= rfree) {
                        if (source >= rtarget) {
                            res = Math.min(res, source);
                        } else {
                            if (rtarget - source <= rextra) {
                                res = Math.min(res, rtarget);
                            }
                        }
                    }
                }
                if (res == Integer.MAX_VALUE) res = -1;
                cout.println(res);
            } catch (RuntimeException e) {
                e.printStackTrace();
                return;
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }

        }
    }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 1000000);
            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());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}