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.*;

import java.math.BigInteger;
import java.util.*;

public class TaskC {

    static ArrayList<Long>al;
    static int n, m, ans;
    static int[]arr;
    static int[] row = new int[9];

    public static void backtrack(int col)
    {
        if(col==9)
        {
            ans++;
            System.out.println(Arrays.toString(row));
            return;
        }
        for(int i = 1; i <= 8;i++)
            if(valid(col,i))
            {
                row[col] = i;
                backtrack(col+1);
            }

    }

    public static boolean valid(int col, int tryRow)
    {
        for(int i = 1; i < col; i++)
            if(row[i]==tryRow || Math.abs(tryRow-row[i])== Math.abs(col-i))
                return false;
        return true;
    }

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        int d = sc.nextInt();
        int[]arr = new int[n];

        HashMap<Integer , Integer> map = new HashMap<>();

        for (int i = 0 ; i < n ; i++)
        {
            int x = sc.nextInt();
            arr[i] = x;
        }
        long  ans = 0;
        for (int i = 0,j = 1 ; i < n ; i++)
        {
            while (j < n && arr[i] + d >= arr[j]) {
                j++;
                if(j == n && arr[i] + d >= arr[j - 1]){
                    j--;
                    break;
                }
                if(arr[i] + d < arr[j])
                {
                    j--;
                    break;
                }
            }

            ans+= (1l*(j - i)*(j - i -1)) / 2;
        }

        pw.print(ans);
        pw.close();

    }



    private static long gcd(long a, long b) {
        if( b == 0)
            return a;
        return gcd(b  , a%b);
    }

    static long lcm(int a, int b)
    {
        return (a*b)/gcd(a, b);
    }


    private  static int dis(int xa , int ya , int xb , int yb)
    {
        return (xa-xb)*(xa - xb) + (ya- yb)*(ya-yb);
    }


    static class Pair implements Comparable<Pair> {
        double x,y;


        public Pair(double x, double y) {
            this.x = x;
            this.y = y;
        }

        public int compareTo(Pair o) {
           /* if (x == o.x)
                return y - o.y;
            return x - o.x;*/
           return  0;
        }
        public double dis(Pair a){

            return (a.x - x)*(a.x - x) + (a.y-y)*(a.y-y);
        }

        public String toString() {
            return  x+" "+ y;
        }
        public boolean overlap(Pair a)
        {
        if((this.x >= a.x && this.x <= a.y) || (a.x >= this.x && a.x <= this.y)) return true;
            return false;

        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

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

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

        public boolean check() {
            if (!st.hasMoreTokens())
                return false;
            return true;
        }

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

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

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        public double nextDouble() {
            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() {
            try {
                return br.ready();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}