#include <bits/stdc++.h>
using namespace std;
int main() {
  int v1, v2, t, d, i;
  long long ans = 0;
  cin >> v1 >> v2 >> t >> d;
  ans += fabs(v1 + v2);
  int b[105], c[105], val[105];
  int vf = v2, vi = v1;
  for (i = 1; i <= t - 2; i++) {
    vi += d;
    b[i] = vi;
  }
  for (i = t - 2; i >= 1; i--) {
    vf += d;
    c[i] = vf;
  }
  for (i = 1; i <= t - 2; i++) {
    val[i] = min(c[i], b[i]);
    ans += val[i];
  }
  cout << ans << endl;
  return 0;
}
