def calculate_time(a, b, n, times):
total_time=0
cycle_time=a+b
for t in times:
arrival_time=t%cycle_time
if arrival_time>=a:
wait_time=cycle_time-arrival_time
total_time+=wait_time
return total_time
a, b=map(int, input().split())
n=int(input())
times=list(map(int, input().split()))
result=calculate_time(a, b, n, times)
print(result)