#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[10000];
  int v11, v22, t, d;
  cin >> v11 >> v22 >> t >> d;
  int v2 = max(v11, v22);
  int v1 = min(v11, v22);
  a[0] = v1;
  a[t - 1] = v2;
  for (int i = 1; i < t - 1; i++) {
    a[i] = a[i - 1] + d;
  }
  for (int j = t - 2; j > 0; j--) {
    if (a[j] - a[j + 1] > d) {
      a[j] = a[j + 1] + d;
    }
  }
  long long int sum = 0;
  for (int i = 0; i < t; i++) sum += a[i];
  cout << sum << endl;
}
