#include <bits/stdc++.h>
using namespace std;
int main() {
  int start;
  int end;
  int sec;
  int d;
  cin >> start >> end >> sec >> d;
  int a = max(start, end);
  int b = min(start, end);
  int m = sec - 2;
  int sum = a + b;
  for (int i = 1; i <= sec - 2; i++) {
    a += d;
  end:
    if (a - (m * d) > b) {
      a--;
      goto end;
    }
    m--;
    sum += a;
  }
  cout << sum;
  return 0;
}
