#include <bits/stdc++.h>
using namespace std;
void splitstr(const string &s, vector<string> &v) {
  istringstream in(s);
  copy(istream_iterator<string>(in), istream_iterator<string>(),
       back_inserter(v));
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
int main() {
  ios_base::sync_with_stdio(0);
  int n = 0, a = 0, arr[100004], t = 0, k = 0, m = 0, i = 0, j = 0, ans = 0,
      b = 0, c = 0, d = 0, x = 0, y = 0, f = 0, l = 0, r = 0;
  string str, s;
  int v1, v2;
  cin >> v1 >> v2 >> t >> d;
  if (v1 > v2) swap(v1, v2);
  ans = v1 + v2;
  t -= 2;
  for (int i = t; i >= 1; i--) {
    if (v1 + d <= v2 + i * d) {
      v1 += d;
      ans += v1;
    } else {
      v2 += d;
      ans += v2;
    }
  }
  cout << ans << '\n';
  return 0;
}
