#include <bits/stdc++.h>
using namespace std;
int main() {
  int v1, v2, t, d;
  cin >> v1 >> v2 >> t >> d;
  int a[105], b[105];
  a[1] = v1;
  b[t] = v2;
  for (int i = 2; i <= t; i++) a[i] = a[i - 1] + d;
  for (int i = t - 1; i >= 1; i--) b[i] = b[i + 1] + d;
  if (d > 0) {
    int turn = (d + d * t + v2 - v1) / (2 * d);
    int ans = 0;
    for (int i = 1; i <= turn; i++) ans += a[i];
    for (int i = turn + 1; i <= t; i++) ans += b[i];
    cout << ans << endl;
  } else
    cout << v1 * t << endl;
}
