#include <bits/stdc++.h>
using namespace std;
int v1, v2, t, d;
int main() {
  cin >> v1 >> v2 >> t >> d;
  vector<int> a, b;
  for (int i = 0; i < t - 1; i++) {
    a.push_back(v1 + i * d);
    b.push_back(v2 + i * d);
  }
  reverse(b.begin(), b.end());
  vector<int> c;
  for (int i = 0; i < t - 1; i++) {
    if (abs(a[i] - b[i]) <= d) {
      c.push_back(i);
    }
  }
  int maxn = -1, maxi = -1;
  for (int i : c) {
    if (a[i] + b[i] > maxn) {
      maxn = a[i] + b[i];
      maxi = i;
    }
  }
  if (maxn == -1 || maxi == -1) {
    cout << "ERROR" << endl;
    return 0;
  }
  int tot = 0;
  for (int i = 0; i <= maxi; i++) {
    tot += a[i];
  }
  for (int i = maxi; i < t - 1; i++) {
    tot += b[i];
  }
  cout << tot << endl;
}
