#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, t, d, sum = 0, p;
  cin >> l >> r >> t >> d;
  int a[t];
  p = t - 1;
  if (l < r) {
    l = l + r;
    r = l - r;
    l = l - r;
  }
  a[0] = l;
  a[p] = r;
  p--;
  while ((a[p + 1] < l) && (p != 0)) {
    a[p] = a[p + 1] + d;
    p--;
  }
  l = 1;
  r = p;
  while (l <= r) {
    a[l] = a[l - 1] + d;
    l++;
    if (l <= r) {
      a[r] = a[r + 1] + d;
      r--;
    }
  }
  for (int i = 0; i < t; i++) sum += a[i];
  cout << sum;
}
