#include <bits/stdc++.h>
using namespace std;
int v1, v2, t, d, sm, art;
int main() {
  cin >> v1 >> v2 >> t >> d;
  if (t == 2) {
    cout << v1 + v2;
    return 0;
  }
  sm = v1 + v2, art = v1 + d;
  for (int i = 2; i < t; i++) sm += art, art += d;
  art -= d;
  for (int i = t; i >= 1; i--) {
    if (abs(art - v2) > d) {
      sm -= abs(art - v2) - d;
      v2 = art - (abs(art - v2) - d);
      art -= d;
    }
  }
  cout << sm;
}
