Recursion - 2#329

Recursion - 2

1 second
128 megabytes
Very easy (≈850)

Three numbers a, b, c are given. Calculate the value of the function for a given number :

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

Input

Four integers a, b, c~(|a|, |b|, |c| \leq 1000), n~(0 \leq n \leq 1000) are given.

Output

Output the value of the function .

Examples

Example 1

Loading
Loading