Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.

Note that the order of the points inside the group of three chosen points doesn't matter.

Input

The first line contains two integers: n and d (1 ≤ n ≤ 105; 1 ≤ d ≤ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 — the x-coordinates of the points that Petya has got.

It is guaranteed that the coordinates of the points in the input strictly increase.

Output

Print a single integer — the number of groups of three points, where the distance between two farthest points doesn't exceed d.

Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

4 3
1 2 3 4


Output

4


Input

4 2
-3 -2 -1 0


Output

2


Input

5 19
1 10 20 30 50


Output

1

Note

In the first sample any group of three points meets our conditions.

In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.

In the third sample only one group does: {1, 10, 20}.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Stack;
import java.util.StringTokenizer;

public class codeforcesreturn {
	static class pair implements Comparable<pair> {
		int left;
		int right;

		public pair(int l, int r) {
			left = l;
			right = r;
		}

		public int compareTo(pair p) {
			return left-p.left;
	}
	}
	static ArrayList<Integer>[] adjlist;
	static int[][] adjmatrix;
	static int[][] adjmatrix2;
	static boolean[] vis;
	static boolean[] intialvis;
	static boolean[] vis2;
	static int[] counter;
	static int V, E;
	static Stack<Integer> st;
	static ArrayList<Integer> arrylist;
	static boolean flag;
	static int[] dx = new int[] { 1, -1, 0, 0 };
	static int[] dy = new int[] { 0, 0, 1, -1 };
	static int[] Arr;
	static PrintWriter pw;

	static long bin(long d,int startindex, int[] Arr) {
		int left = startindex+2;
		int right = Arr.length-1;
		int mid;
		int ans = 0;
		while (left <= right) {
			mid = (left + right) / 2;
			if (Arr[mid]-Arr[startindex]<=d) {
				ans = mid;
				left = mid + 1;
			} else {
				right = mid - 1;
			}
		}
	//	System.out.println(ans);
		if(ans==0)return 0;
		long dif=ans-startindex-1;
		return (dif+1)*dif/2;
	}

	static boolean check(int k, int w, int[] Arr) {
		int n = Arr.length;
		HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
		int c = 0;
		for (int i = 0; i < w; i++) {
			c += hm.getOrDefault(Arr[i] * k, 0);
			if (Arr[i] % k == 0)
				c += hm.getOrDefault(Arr[i] / k, 0);
			hm.put(Arr[i], hm.getOrDefault(Arr[i], 0) + 1);
		}
		if (c == 0)
			return true;
		for (int i = 0; i < n - w ; i++) {
			// remove
			c -= hm.getOrDefault(Arr[i] * k, 0);
			if (Arr[i] % k == 0)
				c -= hm.getOrDefault(Arr[i] / k, 0);
			if(hm.get(Arr[i])==1)
				hm.remove(Arr[i]);
			else
				hm.put(Arr[i], hm.getOrDefault(Arr[i], 0) - 1);
			// add
			c += hm.getOrDefault(Arr[i+w] * k, 0);
			if (Arr[i+w] % k == 0)
				c += hm.getOrDefault(Arr[i+w] / k, 0);
			hm.put(Arr[i+w], hm.getOrDefault(Arr[i+w], 0) + 1);
			if (c == 0)
				return true;
		}
		return false;
	}

	public static void main(String[] args) throws IOException, InterruptedException {
		pw = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d=sc.nextInt();
		int[] Arr=new int[n];
		for(int i=0;i<n;i++)
			Arr[i]=sc.nextInt();
		long sum=0;
		for(int i=0, j=2;i<n-2;i++){
			long max=0;
			while(j<n&&Arr[j]-Arr[i]<=d){
				 max=j-i-1;
				 j++;
			}
			j--;
			sum+=(max+1)*max/2;
		}
		System.out.println(sum);
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}
