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.util.StringTokenizer;

public class Code implements Runnable {

    public static void main(String[] args) throws IOException {
        new Thread(new Code()).start();
    }

    private void solve() throws IOException {
        int n = nextInt(), d = nextInt();

        int[] points = new int[n];
        for(int i = 0; i < n; ++i) {
            points[i] = nextInt();
        }

        long[] sum = new long[100001];
        for(int i = 1; i <= 100000; ++i) {
            sum[i] = sum[i - 1] + i;
        }

        long answer = 0;
        for(int i = 0; i < n - 2; ++i) {
            int l = i + 2, r = n - 1;
            while (l < r) {
                int mid = l + r >> 1;
                if(points[mid] - points[i] > d)
                    r = mid;
                else
                    l = mid + 1;
            }

            if(points[r] - points[i] > d) {
                if(r - i > 2 && points[r] - points[i] > d && points[r - 1] - points[i] <= d)
                    r -= 1;
                else
                    continue;
            }

            int count = r - i;
            answer += sum[count - 1];
        }

        writer.println(answer);
    }

    private class Pair<E, V> implements Comparable<Pair<E, V>> {
        public Pair(E first, V second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair<E, V> obj) {
            if (first.equals(obj.first)) return ((Comparable) second).compareTo(obj.second);
            return ((Comparable) first).compareTo(obj.first);
        }

        @Override
        public boolean equals(Object obj) {
            Pair other = (Pair) obj;
            return first.equals(other.first) && second.equals(other.second);
        }

        @Override
        public String toString() {
            return first + " " + second;
        }

        public E first;
        public V second;
    }

    @Override
    public void run() {
        try {
            if (in.equals("")) reader = new BufferedReader(new InputStreamReader(System.in));
            else reader = new BufferedReader(new FileReader(in));

            if (out.equals("")) writer = new PrintWriter(new OutputStreamWriter(System.out), false);
            else writer = new PrintWriter(new FileWriter(out), false);
            solve();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            //writer.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + " KB");

            try {
                reader.close();
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private float nextFloat() throws IOException {
        return Float.parseFloat(nextToken());
    }

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

    private String in = "", out = "";
    private BufferedReader reader;
    private PrintWriter writer;
    private StringTokenizer st;
}