a, b, c, d, e = map(int, input().split()) num = b - c l = [d] for i in range(2, 200): if i % 10 != 0: l.append(l[-1]) else: if e <= l[-1]: l.append(l[-1] - e) else: l.append(l[-1]) print(l) print(sum(l[:num]) * a)