#include <bits/stdc++.h>
using namespace std;
int a, b, t, d, v[555];
int main() {
  cin.sync_with_stdio(false);
  cin >> a >> b >> t >> d;
  if (a > b) swap(a, b);
  v[t] = b;
  for (int i = t - 1; i; --i) v[i] = v[i + 1] + d;
  int vc = a, r = a;
  for (int i = 2; i <= t; ++i) {
    vc = min(vc + d, v[i]);
    r += vc;
  }
  cout << r;
}
