#include <bits/stdc++.h>
using namespace std;
int st, en, step, c, ans, m;
int main() {
  scanf("%d %d\n%d %d", &st, &en, &c, &step);
  c -= 2;
  ans = st + en;
  while (c) {
    if (st > en) swap(st, en);
    m = min(st + step, en + step);
    ans += m;
    st = m;
    c--;
  }
  printf("%d", ans);
  return 0;
}
