#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int dp[200][2000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int v1, v2, t, d;
  int i, j, k;
  cin >> v1 >> v2;
  cin >> t >> d;
  memset(dp, -1, sizeof(dp));
  dp[1][v1] = 0;
  for (i = 2; i < t + 1; i++)
    for (j = 1; j < 1500; j++)
      for (k = max(0, j - d); k < min(j + d, 1500) + 1; k++)
        if (dp[i - 1][k] != -1) dp[i][j] = max(dp[i][j], dp[i - 1][k] + j);
  cout << dp[t][v2] + v1 << endl;
  return 0;
}
