#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15 + 5;
struct segtree {
  int size;
  vector<long long> sums;
  void init(int n) {
    while (size < n) size *= 2;
    sums.assign(2 * size, 0LL);
  }
};
bool comparer(const pair<long long, int> &a, const pair<long long, int> &b) {
  return (a.first > b.first);
}
long long power(long long a, long long b, long long c) {
  a %= c;
  if (b == 0) return 1;
  if (a == 0) return 0;
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % c;
    a = (a * a) % c;
    b = b >> 1;
  }
  return ans;
}
long long inverse(long long i) {
  if (i == 1) return 1;
  return (1000000007 -
          ((1000000007 / i) * inverse(1000000007 % i)) % 1000000007 +
          1000000007) %
         1000000007;
}
void solve() {
  int v1, v2, t, d, ans = 0;
  cin >> v1 >> v2 >> t >> d;
  vector<vector<int>> dp(t, vector<int>(2));
  dp[0][0] = v1;
  dp[t - 1][1] = v2;
  for (int i = 1; i < t - 1; i++) {
    dp[i][0] = dp[i - 1][0] + d;
  }
  for (int i = t - 2; i > 0; i--) {
    dp[i][1] = dp[i + 1][1] + d;
  }
  for (int i = 1; i < t - 1; i++) {
    ans += min(dp[i][0], dp[i][1]);
  }
  ans += v1 + v2;
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
