#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> mymap;
int find(int v1, int v2, int t, int d) {
  if (v1 < 0) return INT_MIN;
  if (t == 1) {
    if (v1 == v2) return v2;
    return INT_MIN;
  }
  pair<int, int> a = make_pair(v1, t);
  if (mymap.find(a) != mymap.end()) return mymap[a];
  int maxi = INT_MIN;
  maxi = max(find(v1, v2, t - 1, d), maxi);
  for (int i = 1; i <= d; i++) {
    maxi = max(find(v1 + i, v2, t - 1, d), maxi);
    maxi = max(find(v1 - i, v2, t - 1, d), maxi);
  }
  mymap[a] = maxi + v1;
  return mymap[a];
}
int main() {
  int v1, v2, t, d;
  cin >> v1 >> v2 >> t >> d;
  cout << find(v1, v2, t, d);
}
