#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9 + 1;
constexpr long long LLINF = 1e18 + 1;
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int s, dest, t, d;
  cin >> s >> dest >> t >> d;
  vector<vector<int> > dp(t, vector<int>(1101, -INF));
  dp[0][s] = s;
  for (int i = 0; i < t - 1; i++) {
    for (int j = 0; j < 1101; j++)
      if (dp[i][j] != -INF) {
        for (int k = 0; k <= d; k++) {
          dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] + k + j);
          if (j - k >= 0)
            dp[i + 1][j - k] = max(dp[i + 1][j - k], dp[i][j] + j - k);
        }
      }
  }
  printf("%d\n", dp[t - 1][dest]);
}
