Grand Opening

Given N bowls to produce and a multiset of wok sizes, each round uses one wok or two distinct woks of equal size, and you must reach exactly N bowls with the fewest rounds.

Medium5Dynamic programmingGreedyImplementationMathInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

Haebin loves jjajangmyeon so much that he opened a Chinese restaurant selling nothing else. He is ambidextrous, so he can hold two woks at once and cook with both in a single round.

A wok

Haebin hates waste, so he always fills a wok completely. A round that uses one wok produces exactly that wok's size in bowls, and a round that uses two woks produces exactly the sum of the two sizes. A wok that holds 4 bowls produces 4 bowls, never 3 and never 5. The two woks used together must be two different woks, so he can produce 2c2c bowls in one round only when he owns two woks of size cc. A wok is free again once its round ends, and he can reuse it as many times as he likes.

The order is exactly NN bowls, and the bowls produced over all rounds must add up to NN.

Say the order is 5 bowls and the woks have sizes 1 and 3. Haebin first uses the size 1 wok and the size 3 wok together for 4 bowls, then the size 1 wok alone for 1 bowl, filling the order in two rounds.

Given the number of bowls ordered and the sizes of the woks, find the smallest number of rounds that fills the order.

Input

The first line contains the number of bowls ordered, NN (1N100001 \le N \le 10\,000), and the number of woks, MM (1M1001 \le M \le 100), separated by a space. The second line contains the wok sizes S1,S2,,SMS_1, S_2, \dots, S_M (1SiN1 \le S_i \le N), separated by spaces. Haebin can own several woks of the same size.

Output

Print the smallest number of cooking rounds that fills the order. If no sequence of rounds produces exactly NN bowls, print -1.

Hint

With woks of size 1 and 3 and an order of 6 bowls, Haebin cooks 3 bowls with the size 3 wok and then cooks 3 more the same way, filling the order in two rounds.