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.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.io.*;
import java.math.*;

public class CC
{
    public static void main(String[] args)
    {
        StringBuffer sb = new StringBuffer();
        //int t=i();
        //while (t-->0)
        //{
          int n=i(),d=i();
          int A[]=new int[(int)n];
          for(int i=0;i<A.length;i++)
              A[i]=i();

          long cnt=0;
        if(n>2) {
             for(int i=0;i<n;i++)
             {
                 long pp=Arrays.binarySearch(A,A[i]+d);
                 //System.out.println(pp);
                 if(pp>0){
                     cnt+=(pp-i)*(pp-1-i)/2;
                 }
                 else {
                     pp=pp*-1-2;
                     if(pp<=n-1){
                         cnt+=(pp-i)*(pp-i-1)/2;
                     }
                     else {
                         pp=n-1;
                         cnt+=(pp-i)*(pp-i-1)/2;

                     }
                 }


             }

        }
          if(n==1||n==2)
              cnt=0;


       sb.append(cnt+"\n");
       // }






        System.out.println(sb.toString());
}
/*static int  binary(int A[],int k,int l,int h)
{
    while (l<h)
    {
        int mid=(l+h)/2;
        if(A[mid]<=k&&A[mid+1]>k)
            return mid+1;

        if(A[mid]<=k)
        {
            l=mid+1;
        }
        else{
            h=mid-1;
           }

    }
    return -1;
}*/
 //********************************Class pair******************************************************************************************************************************************///////////////////////////////////////////////////////////////////////////////////////////////
    static class pair implements Comparable<pair>
    {
        int x,y;
        pair(int x,int y){
            this.x=x;
            this.y=y;
        }
        public boolean equals(Object obj)
        {
            if(this==obj)
                return true;
            if(obj==null||obj.getClass()!=this.getClass())
                return false;
            pair other=(pair)obj;
            return (this.x==other.x&&this.y==other.y);

        }
        public int hashCode(){
            return (1000000000+ x*100000 + 100*y+1000);
        }
        public int compareTo(pair o)
        {
            return this.hashCode()-o.hashCode();
        }
        public String toString()
        {
            return String.valueOf(hashCode());
        }
    }
//-------------------prime factorization********/***************************************************************************************************************************************///////////////////////////////////
static TreeMap primefactorize(long n)
{
    TreeMap<Integer,Integer>h=new TreeMap<>();
    long number=n;
    for(int i=2;i<=Math.sqrt(n);i++)
    {
        if(n%i==0)
        {
            int cnt=0;
            while(n%i==0)
            {
                n=n/i;
                cnt++;
            }
            h.put(i,cnt);
        }
    }
    if(n!=1)
        h.put((int)n,1);
    return h;
}
///******************************SYSTEM PART*****************************************************************************************************************************************************************************************************************************************************////
    static InputReader in=new InputReader(System.in);
    static OutputWriter out=new OutputWriter(System.out);

    public static long pow(long a, long b)
    {
        long result=1;
        while(b>0){
            if (b % 2 != 0){
                result=(result*a);
                b--;
            }
            a=(a*a);
            b /= 2;
        }
        return result;
    }
    public static long gcd(long a, long b){
        if (a == 0){
            return b;
        }
        return gcd(b%a, a);
    }
    public static long lcm(long a, long b){
        return a*(b/gcd(a,b));
    }
    public static long l(){
        String s=in.String();
        return Long.parseLong(s);
    }
    public static void pln(String value){
        System.out.println(value);
    }
    public static int i(){
        return in.Int();
    }
    public static String s(){
        return in.String();
    }
}
///******************input Reader//***************************************************************************************************************************************************************************************
class InputReader
{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;
    public InputReader(InputStream stream) {
        this.stream = stream;
    }
    public int read() {
        if (numChars== -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }
    public int Int() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
    public String String() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
    public String next() {
        return String();
    }
    public interface SpaceCharFilter
    {
        public boolean isSpaceChar(int ch);
    }
}

//*******************OUTPUT WRITER********************************************************************************************************************************************************************************************************************************************************//
class OutputWriter {
    private final PrintWriter writer;
    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }
    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }
    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }
    public void printLine(Object...objects) {
        print(objects);
        writer.println();
    }
    public void close() {
        writer.close();
    }
    public void flush() {
        writer.flush();
    }
}







