INF = 1i64 << 60 n, m, a32, b32 = read_line.split.map(&.to_i) a = a32.to_i64 b = b32.to_i64 c = read_line.split.map(&.to_i).to_set divs = [1] d = 2i64 while d * d <= n if n % d == 0 divs << d.to_i divs << n // d if d * d != n end d += 1 end oks = {n => 0i64} divs.sort.reverse_each do |d| cs = c.select { |v| v % d == 0 } max = (cs.empty? ? n : cs.min) // d cn = n // d best = INF if cs.empty? best = (d == 1 ? 0i64 : b) + a * (cn - 1) end cd = 2i64 while cd * cd <= cn && cd < max if cn % cd == 0 if oks.has_key?(d * cd) best = {best, oks[d * cd] + (d == 1 ? 0i64 : b) + a * (cd - 1)}.min end if cn // cd < max && oks.has_key?(d * (cn // cd)) best = {best, oks[d * (cn // cd)] + (d == 1 ? 0i64 : b) + a * (cn // cd - 1)}.min end end cd += 1 end if best != INF oks[d] = best end end puts oks.has_key?(1) ? oks[1] : -1