1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
h, w = list(map(int, input().split()))
n = int(input())
sizes = list(map(int, input().split()))

if h % sizes[0] != 0 or w % sizes[0] != 0:
    print(-1)
else:
    c = [((h // s) * (w // s)) for s in sizes]
    images = 0
    for i in range(n - 1, -1, -1):
        images += c[i]
        c = [count - ((c[i] * sizes[i] * sizes[i]) // (sizes[j] * sizes[j])) for j, count in enumerate(c)]
    print(images)