The Little Elephant has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai.

The Little Elephant wants to count, how many pairs of integers l and r are there, such that 1 ≤ l < r ≤ n and sequence b = a1a2... alarar + 1... an has no more than k inversions. 

An inversion in sequence b is a pair of elements of the sequence b, that change their relative order after a stable sorting of the sequence. In other words, an inversion is a pair of integers i and j, such that 1 ≤ i < j ≤ |b| and bi > bj, where |b| is the length of sequence b, and bj is its j-th element.

Help the Little Elephant and count the number of the described pairs.

Input

The first line contains two integers n and k (2 ≤ n ≤ 105, 0 ≤ k ≤ 1018) — the size of array a and the maximum allowed number of inversions respectively. The next line contains n positive integers, separated by single spaces, a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of array a.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

Output

In a single line print a single number — the answer to the problem.

Examples

Input

3 1
1 3 2


Output

3


Input

5 2
1 3 2 1 7


Output

6
#include <bits/stdc++.h>
const long long MAX_N = 3e5 + 100;
const long long MOD = 1e9 + 7;
using namespace std;
long long a[MAX_N];
long long l[MAX_N];
long long r[MAX_N];
vector<int> seg[MAX_N];
long long n, k, y;
void build(int k) {
  if (k >= y) return;
  build(k * 2);
  build(k * 2 + 1);
  int p1 = 0, p2 = 0;
  while (p1 < seg[k * 2].size() and p2 < seg[k * 2 + 1].size()) {
    if (seg[k * 2][p1] < seg[k * 2 + 1][p2])
      seg[k].push_back(seg[k * 2][p1++]);
    else
      seg[k].push_back(seg[k * 2 + 1][p2++]);
  }
  if (p1 < seg[k * 2].size())
    while (p1 < seg[k * 2].size()) seg[k].push_back(seg[k * 2][p1++]);
  else if (p2 < seg[k * 2 + 1].size())
    while (p2 < seg[k * 2 + 1].size()) seg[k].push_back(seg[k * 2 + 1][p2++]);
}
long long ask(int l, int r, int a, int b, int k, int x, int d) {
  if (r < a or b < l) return 0;
  if (a <= l and r <= b) {
    if (!seg[k].size()) return 0;
    if (!d) {
      if (seg[k][seg[k].size() - 1] <= x) return 0;
      if (seg[k][0] > x) return seg[k].size();
      int s = 0;
      int e = seg[k].size() - 1;
      while (e - s > 1) {
        int mid = (e + s) / 2;
        if (seg[k][mid] <= x)
          s = mid;
        else
          e = mid;
      }
      return seg[k].size() - e;
    } else {
      if (seg[k][0] >= x) return 0;
      if (seg[k][seg[k].size() - 1] < x) return seg[k].size();
      int s = 0;
      int e = seg[k].size() - 1;
      while (e - s > 1) {
        int mid = (e + s) / 2;
        if (seg[k][mid] < x)
          s = mid;
        else
          e = mid;
      }
      return s + 1;
    }
  }
  int mid = (l + r) / 2;
  return (ask(l, mid, a, b, k * 2, x, d) +
          ask(mid + 1, r, a, b, k * 2 + 1, x, d));
}
int main() {
  cin >> n >> k;
  y = (1ll << ((int)ceil(log2(n))));
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    seg[i + y].push_back(a[i]);
  }
  build(1);
  for (int i = 1; i <= n; ++i)
    l[i] = l[i - 1] + ask(0, y - 1, 0, i - 1, 1, a[i - 1], 0);
  for (int i = n; i >= 1; --i)
    r[i] = r[i + 1] + ask(0, y - 1, i - 1, n - 1, 1, a[i - 1], 1);
  long long ans = 0;
  long long p = n - 1;
  long long now = 0;
  for (int i = n; i > 1 and p > 0; --i) {
    if (r[i] > k) break;
    if (p == i) {
      now -= ask(0, y - 1, i - 1, n - 1, 1, a[p - 1], 1);
      p--;
    }
    if (!p) break;
    while (ask(0, y - 1, 0, p - 1, 1, a[i - 1], 0) + l[p] + r[i] + now > k and
           p > 0) {
      now -= ask(0, y - 1, i, n - 1, 1, a[p - 1], 1);
      p--;
    }
    ans += p;
    if (p) now += ask(0, y - 1, 0, p - 1, 1, a[i - 1], 0);
  }
  cout << ans;
  return 0;
}
