#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, n, d, s = 0;
  cin >> a >> b >> n >> d;
  vector<int> v(n);
  v[0] = min(a, b);
  v[n - 1] = max(a, b);
  for (int i = 1; i < n - 1; ++i) v[i] += v[i - 1] + d;
  for (int i = n - 2; i; --i) {
    while (abs(v[i] - v[i + 1]) > d) --v[i];
    s += v[i];
  }
  cout << s + v[0] + v[n - 1];
  return 0;
}
