#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int res = 0;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res;
}
const int N = 100010;
int main() {
  int start = in(), end = in();
  if (start > end) swap(start, end);
  int n = in(), d = in();
  int ans = start + end;
  int v = start;
  for (int i = 2; i < n; i++) {
    v = min(v + d, end + (n - i) * d);
    ans += v;
  }
  printf("%d\n", ans);
  return 0;
}
