eolymp
bolt
Try our new interface for solving problems
Problems

Recursion - 2

Recursion - 2

Time limit 1 second
Memory limit 128 MiB

The integers a, b, c are given. Implement the recursive function:

f(n) = \begin{cases} a, n = 0\\f(n - 1) + bn + c, n > 0\end{cases}

Input data

Four integers a, b, c\:(|a|, |b|, |c| \le 1000), n\:(0 \le n \le 1000).

Output data

Print the value of f(n).

Examples

Input example #1
4 2 -3 10
Output example #1
84
Author Michael Medvediev