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}.
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long double PI = acos(-1.0);
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int ceil2(long long int a, long long int b) {
  long long int c = a / b;
  if (a % b) c++;
  return c;
}
bool isPalindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}
long long int lowerIndex(vector<long long int> &arr, long long int x) {
  long long int n = arr.size();
  long long int l = 0, h = n - 1;
  while (l <= h) {
    long long int mid = (l + h) / 2;
    if (arr[mid] >= x)
      h = mid - 1;
    else
      l = mid + 1;
  }
  return l;
}
long long int upperIndex(vector<long long int> &arr, long long int y) {
  long long int n = arr.size();
  long long int l = 0, h = n - 1;
  while (l <= h) {
    long long int mid = (l + h) / 2;
    if (arr[mid] <= y)
      l = mid + 1;
    else
      h = mid - 1;
  }
  return h;
}
long long int countInRange(vector<long long int> &arr, long long int x,
                           long long int y) {
  long long int n = arr.size();
  long long int count = 0;
  count = upperIndex(arr, y) - lowerIndex(arr, x) + 1;
  return count;
}
void solve() {
  long long int n, d;
  cin >> n >> d;
  set<long long int> s;
  vector<long long int> arr(n);
  for (int i = 0; i < n; i++) {
    long long int t;
    cin >> t;
    arr[i] = t;
    s.insert(t);
  }
  long long int res = 0;
  for (auto it1 : s) {
    long long int key = countInRange(arr, it1 + 1, it1 + d);
    res = res + ((key) * (key - 1)) / 2;
  }
  cout << res << "\n";
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
