#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 1e3 + 100;
const int INF = 1e5;
int v1, v2, t, d, memo[MAXN][MAXN];
int f(int v, int i) {
  if (v < 0) {
    return -INF;
  }
  if (i == t) {
    if (v == v2) {
      return 0;
    } else {
      return -INF;
    }
  }
  if (memo[v][i] != -1) {
    return memo[v][i];
  }
  int ans = f(v, i + 1) + v;
  for (int j = 0; j <= d; j++) {
    ans = max({ans, f(v - j, i + 1) + v - j, f(v + j, i + 1) + v + j});
  }
  memo[v][i] = ans;
  return ans;
}
void solve() {
  cin >> v1 >> v2 >> t >> d;
  memset(memo, -1, sizeof(memo));
  cout << (v1 + f(v1, 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}
