#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return !a ? b : gcd(b % a, a); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int mod = 1e9 + 7;
long long FastPowMod(long long x, long long p) {
  if (p == 1) return x;
  if (p % 2 == 0)
    return FastPowMod((x % mod) * (x % mod), p / 2) % mod;
  else
    return ((FastPowMod((x % mod) * (x % mod), p / 2) % mod) * (x % mod)) % mod;
}
int main() {
  int v1, v2, t, d, sum = 0, diff = 0;
  bool valid = true;
  scanf("%d%d%d%d", &v1, &v2, &t, &d);
  sum = v1;
  for (int i = 2; i <= t; i++) {
    valid = false;
    if (v1 + d <= v2) {
      v1 = v1 + d;
      sum += v1;
    } else {
      for (int j = d; j >= 0; j--) {
        diff = (v1 + j) - v2;
        if (ceil((double)diff / d) <= t - i) {
          v1 += j;
          sum += v1;
          valid = true;
          break;
        }
      }
      if (valid == false) {
        for (int j = 0; j <= d; j++) {
          diff = (v1 - j) - v2;
          if (ceil((double)diff / d) <= t - i) {
            v1 = v1 - j;
            sum += v1;
            break;
          }
        }
      }
    }
  }
  cout << sum;
  return 0;
}
