#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int sz = 1e6 + 10;
const int mod = 1000007;
ll dp[127][1500], t, v1, v2, d;
ll rec(int i, ll val) {
  if (i >= t) return val == v2 ? val : 0;
  if (val < 0) return 0;
  ll& ret = dp[i][val];
  if (~ret) return ret;
  ret = 0;
  ll hand;
  for (int k = 0; k <= d; k++) {
    hand = rec(i + 1, val + k);
    if (hand) ret = max(ret, val + hand);
    hand = rec(i + 1, val - k);
    if (hand) ret = max(ret, val + hand);
  }
  return ret;
}
int main() {
  while (cin >> v1 >> v2 >> t >> d) {
    memset(dp, -1, sizeof dp);
    cout << rec(1, v1) << "\n";
  }
  return 0;
}
