1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
h,w = map(int, input().split())

n = int(input())
d = list(map(int, input().split()))

s = 0

last = 0

if h%d[0]!=0 or w%d[0]!=0:
    print(-1)

else:
    for i in reversed(d):
        l = h//i
        r = w//i
        s += l*r
        s-= last//(i*i)
        last = l*r*i*i

    print(s)