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.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;

public class cf252b_pol {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Long getLong() {
        try {
            return Long.parseLong(br.readLine());
        } catch (Exception e) {
        }
        return 0l;
    }

    public static Long[] getIntArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Long temp2[] = new Long[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Long.parseLong(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static double nextDouble() {
        return sc.nextDouble();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        StringBuilder out = new StringBuilder();
        int temp = a;
        while (temp > 0) {
            //out = temp % base + out;
            out.insert(0, temp % base);
            temp /= base;
        }
        return out.toString();
    }

    public static void main(String[] ar) {
        //main2();

        Long temp[] = getIntArr();
        long n = temp[0];
        long d = temp[1];

        Long input[] = getIntArr();
        long out = 0;
        for (int i = 0; i < n - 2; i++) {
            long a = input[i];

            int l = i + 2, r = (int) n - 1;

            while (l != r) {
                int mid = (l + r) / 2;
                long b = input[mid];
                long cur_dis = Math.abs(a - b);
                if (cur_dis > d) {
                    // if(a==47){
                    //print("tukar right"+input[r] + " ke "+input[mid]);
                    // }
                    r = mid;
                } else {
                    // if(a==47){
                    //print("tukar left"+input[l] + " ke "+input[mid+1]);
                    // }
                    l = mid + 1;
                }
            }
            //print(a +" dengan "+input[l]);
            if (Math.abs(a - input[l]) <= d) {
                // 
                out += getSum(i, r);
            } else if (Math.abs(a - input[l - 1]) <= d) {
                out += getSum(i, l - 1);
            }
        }
        print(out);



    }

    public static void main2() {
        Long temp[] = getIntArr();
        long n = temp[0];
        long d = temp[1];

        Long input[] = getIntArr();
        long out = 0;
        for (int i = 0; i < n - 2; i++) {
            long a = input[i];


            int l = i + 2, r = (int) n - 1;

            while (l != r) {
                int mid = (l + r) / 2;
                if ((l + r) % 2 == 1) {
                    mid++;
                }
                //print(l+ " " +r);
                //print(a + "dengan " + input[l] + " & " + input[r] + " mid " + input[mid]);

                long b = input[mid];
                long cur_dis = Math.abs(a - b);
                if (cur_dis <= d) {
                    //print(a + " right dengan " + input[l] + " & " + input[r] + " mid " + input[mid] + " berjarak " + cur_dis);
                    l = mid;
                    //print("right menjadi" + (mid));
                } else {
                    //print(a + " left dengan " + input[l] + " & " + input[r] + " mid " + input[mid] + " berjarak " + cur_dis);
                    r = mid - 1;
                    //print("left menjadi" + (mid + 1));
                }
            }
            //l = l > n-1 ? l-1 : l;
            //print(a + " dengan " + input[l]);


            //print(a + " dengan " + input[l]);
            if (Math.abs(a - input[l]) <= d) {
                //print("A");
                out += getSum(i, l);
            }


        }
        print(out);
    }

    static long getSum(int i, int j) {
        long jarak = Math.abs(j - i) - 1;
        if (jarak % 2 == 0) {
            return (jarak + 1) * (jarak / 2);
        }
        return jarak * ((jarak / 2) + 1);
    }
}