#include <bits/stdc++.h>
using namespace std;
void print_set(set<string> &s) {
  set<string>::iterator it = s.begin();
  while (it != s.end()) {
    cout << (*it) << "\n";
    it++;
  }
}
long long p(long long x, long long n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return p(x * x, n / 2);
  else
    return x * p(x * x, (n - 1) / 2);
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
float area(int x1, int y1, int x2, int y2, int x3, int y3) {
  return abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);
}
bool inside_rectangle(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
                      int y4, int x, int y) {
  float A = area(x1, y1, x2, y2, x3, y3) + area(x1, y1, x4, y4, x3, y3);
  float A1 = area(x, y, x1, y1, x2, y2);
  float A2 = area(x, y, x2, y2, x3, y3);
  float A3 = area(x, y, x3, y3, x4, y4);
  float A4 = area(x, y, x1, y1, x4, y4);
  return (A == A1 + A2 + A3 + A4);
}
bool sortinrev(const pair<int, string> &a, const pair<int, string> &b) {
  if (a.first != b.first)
    return (a.first > b.first);
  else
    return (a.second < b.second);
}
long long digitsum(long long a) {
  long long num = a, sum = 0;
  while (num != 0) {
    sum = sum + num % 10;
    num = num / 10;
  }
  if (sum / 10)
    return digitsum(sum);
  else
    return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int d, n;
  long long t;
  long long res = 0;
  cin >> n >> d;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 2; i < n; i++) {
    t = i - (lower_bound(a.begin(), a.end(), a[i] - d) - a.begin());
    res += t * (t - 1) / 2;
  }
  cout << res;
}

### Prompt

Your challenge is to write a Cpp solution to the following problem:

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}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void print_set(set<string> &s) {
  set<string>::iterator it = s.begin();
  while (it != s.end()) {
    cout << (*it) << "\n";
    it++;
  }
}
long long p(long long x, long long n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return p(x * x, n / 2);
  else
    return x * p(x * x, (n - 1) / 2);
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
float area(int x1, int y1, int x2, int y2, int x3, int y3) {
  return abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);
}
bool inside_rectangle(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
                      int y4, int x, int y) {
  float A = area(x1, y1, x2, y2, x3, y3) + area(x1, y1, x4, y4, x3, y3);
  float A1 = area(x, y, x1, y1, x2, y2);
  float A2 = area(x, y, x2, y2, x3, y3);
  float A3 = area(x, y, x3, y3, x4, y4);
  float A4 = area(x, y, x1, y1, x4, y4);
  return (A == A1 + A2 + A3 + A4);
}
bool sortinrev(const pair<int, string> &a, const pair<int, string> &b) {
  if (a.first != b.first)
    return (a.first > b.first);
  else
    return (a.second < b.second);
}
long long digitsum(long long a) {
  long long num = a, sum = 0;
  while (num != 0) {
    sum = sum + num % 10;
    num = num / 10;
  }
  if (sum / 10)
    return digitsum(sum);
  else
    return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int d, n;
  long long t;
  long long res = 0;
  cin >> n >> d;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 2; i < n; i++) {
    t = i - (lower_bound(a.begin(), a.end(), a[i] - d) - a.begin());
    res += t * (t - 1) / 2;
  }
  cout << res;
}

```