The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v1 meters per second, and in the end it is v2 meters per second. We know that this section of the route took exactly t seconds to pass.

Assuming that at each of the seconds the speed is constant, and between seconds the speed can change at most by d meters per second in absolute value (i.e., the difference in the speed of any two adjacent seconds does not exceed d in absolute value), find the maximum possible length of the path section in meters.

Input

The first line contains two integers v1 and v2 (1 ≤ v1, v2 ≤ 100) — the speeds in meters per second at the beginning of the segment and at the end of the segment, respectively.

The second line contains two integers t (2 ≤ t ≤ 100) — the time when the car moves along the segment in seconds, d (0 ≤ d ≤ 10) — the maximum value of the speed change between adjacent seconds.

It is guaranteed that there is a way to complete the segment so that:

  * the speed in the first second equals v1, 
  * the speed in the last second equals v2, 
  * the absolute value of difference of speeds between any two adjacent seconds doesn't exceed d. 

Output

Print the maximum possible length of the path segment in meters. 

Examples

Input

5 6
4 2


Output

26

Input

10 10
10 0


Output

100

Note

In the first sample the sequence of speeds of Polycarpus' car can look as follows: 5, 7, 8, 6. Thus, the total path is 5 + 7 + 8 + 6 = 26 meters.

In the second sample, as d = 0, the car covers the whole segment at constant speed v = 10. In t = 10 seconds it covers the distance of 100 meters.
//package DP;
import java.util.*;
import java.io.*;
public class A{
	static final int mod = (int) 1e9 + 7;
	static final int inf = (int) 1e9;
	static final long INF = (long) 1e18;
    static int dp[][]=new int[101][9001];static int u,v,t,d;
	public static void main(String[] args) throws IOException
	{
		FastScanner fs=new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		fill();
		u=fs.nextInt();v=fs.nextInt();t=fs.nextInt();d=fs.nextInt();
		out.println(solve(1,0));out.close();
	}
	public static int solve(int ind,int prev)
	{
		int ans=-inf;
		if(dp[ind][prev]!=-1)return dp[ind][prev];
		if(ind==1)
		{
			ans=solve(ind+1,u)+u;
			//System.out.println(ans);
			return dp[ind][prev]=ans;
		}
		else if(ind==t)
		{
			if(Math.abs(prev-v)>d)return dp[ind][prev]=-inf;
			else
			{
				//System.out.println(ind+" "+prev+" "+v);
				return dp[ind][prev]=v;
			}
		}
		for(int i=0;i<=d;i++)
		{
			int next=solve(ind+1,prev+i);
			if(next!=-inf)
				ans=Math.max(ans,next+(prev+i));
			if(prev-i>=0)
			{
				int next2=solve(ind+1,prev-i);
				if(next2!=-inf)
					ans=Math.max(ans,next2+(prev-i));
			}
		}
		//System.out.println(ind+" "+ans+" "+prev);
		return dp[ind][prev]=ans;
	}
	public static void fill()
	{
		for(int i=0;i<dp.length;i++)
			Arrays.fill(dp[i],-1);
	}
	// returns the index of the smallest element in the array that is greater than
	// or equal to
	// the given element.
	public static int lower_bound(int arr[], int key) {
		int index = inf, num = 0;
		int left = 0, right = arr.length - 1;
		while (left <= right) {
			int mid = left + (right - left) / 2;
			if (arr[mid] >= key) {
				index = mid;
				num = arr[mid];
				right = mid - 1;
			} else
				left = mid + 1;
		}
		return index == inf ? arr.length : index;
	}

	// returns the index of the smallest element in the array that is less than or
	// equal to
	// the given element.
	public static int upper_bound(int arr[], int key) {
		int index = inf, num = 0;
		int left = 0, right = arr.length - 1;
		while (left <= right) {
			int mid = left + (right - left) / 2;
			if (arr[mid] <= key) {
				index = mid;
				num = arr[mid];
				left = mid + 1;
			} else
				right = mid - 1;
		}
		return index == inf ? arr.length : index;
	}
}

class FastScanner {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = new StringTokenizer("");

	public String next() {
		while (!st.hasMoreTokens())
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		return st.nextToken();

	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	int[] sort(int arr[]) {
		ArrayList<Integer> list = new ArrayList<Integer>();
		for (int i : arr)
			list.add(i);
		Collections.sort(list);
		for (int i = 0; i < arr.length; i++) {
			arr[i] = list.get(i);
		}
		return arr;
	}

	char[] charsort(char arr[]) {
		ArrayList<Character> list = new ArrayList<>();
		for (char c : arr)
			list.add(c);
		Collections.sort(list);
		for (int i = 0; i < list.size(); i++) {
			arr[i] = list.get(i);
		}
		return arr;
	}

	long[] longsort(long arr[]) {
		ArrayList<Long> list = new ArrayList<Long>();
		for (long i : arr)
			list.add(i);
		Collections.sort(list);
		for (int i = 0; i < arr.length; i++) {
			arr[i] = list.get(i);
		}
		return arr;
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public int[] readArray(int left,int right) {
		int[] arr = new int[right-left+1];
		for (int i = left; i <=right; i++)
			arr[i] = nextInt();
		return arr;
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public long[] longreadArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}
