
import java.util.Arrays;
import java.util.Scanner;

public class Coins {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
int n=in.nextInt();int a[]=new int[n];
int q=in.nextInt();
for(int i=0;i<n;i++)
	a[i]=in.nextInt();
Arrays.sort(a);
while(q-->0)
{int c=0;int j=0;
	int qr=in.nextInt();int oqr=qr;
	if(qr>a[n/2])
		j=n-1;
	else
		j=(n/2)-1;
	for(int i=j;i>=0;i--)
	{
		qr=qr%a[i];
		if(qr!=oqr)
			c++;
		oqr=qr;
		if(qr%a[i]==0&&c>0)
			break;
	}
	if(qr!=0)
		System.out.println(-1);
	else
		System.out.println(c);
	
	
}
	}

}
