#include <bits/stdc++.h>
using namespace std;
int main() {
  int v1, v2, t, d;
  cin >> v1 >> v2 >> t >> d;
  if (d == 0) {
    cout << v1 * t;
    return 0;
  }
  int mn = min(v1, v2);
  int mx = max(v1, v2);
  int i = mn, j = mx;
  long long sum = 0;
  for (; i <= mx; i += d) {
    sum += i;
    t--;
  }
  i -= d;
  if (t > 0) {
    sum += j;
    t--;
  }
  while (true) {
    if (t > 1) {
      i += d;
      j += d;
      sum += i + j;
      t -= 2;
    }
    if (t == 1) {
      i += d;
      sum += i;
      t--;
    }
    if (t <= 0) break;
  }
  cout << sum;
}
