#include <bits/stdc++.h>
using namespace std;
unsigned long long int dp[100002] = {0};
unsigned long long int ctr[100002] = {0};
int main() {
  unsigned long long int v1, v2, t, d, V1, V2;
  cin >> V1 >> V2 >> t >> d;
  unsigned long long int sum = 0;
  v1 = min(V1, V2);
  v2 = max(V1, V2);
  sum += v1 + v2;
  for (unsigned long long int i = 2; i < t; i++) {
    if (v1 + d < v2 + (t - i) * d)
      v1 += d;
    else
      v1 = v2 + (t - i) * d;
    sum += v1;
  }
  cout << sum << endl;
  return 0;
}
