#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int v1, v2, t, d, sum, a, t1, t2;
  while (cin >> v1 >> v2 >> t >> d) {
    sum = v1 + v2;
    for (int i = 2; i < t; i++) {
      if (v1 <= v2) {
        v1 += d;
        sum += v1;
      } else {
        v2 += d;
        sum += v2;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
