#45059: python


s210367@student.cysh.cy.edu.tw (張少謙)


g, r = map(int, input().split())
n = int(input())
time = list(map(int, input().split()))
rg = g + r
wtime = 0
for a in time:
    if (a % rg) >= g:
        wtime += (rg - (a % rg))
print(wtime)