#include <bits/stdc++.h>
using namespace std;
int B[102][10005], v1, v2, t, d;
int F(int t, int v1) {
  if (v1 < 0) return -1;
  if (t == 1 && v1 != v2) return -1;
  if (t == 1) return v2;
  if (B[t][v1]) return B[t][v1];
  B[t][v1] = -1;
  for (int i = -d; i <= d; ++i) B[t][v1] = max(B[t][v1], F(t - 1, v1 + i));
  if (B[t][v1] != -1) B[t][v1] += v1;
  return B[t][v1];
}
int main() {
  scanf("%d %d %d %d", &v1, &v2, &t, &d);
  cout << F(t, v1) << endl;
  for (int i = t; i >= 0;) return 0;
}
