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>
using namespace std;
long long ans, k, Sum;
int l, r, n, High, a[1000001], SegTree[7000001], SegTree2[7000001],
    fix[1000001], fixx[1000001];
pair<int, int> p[1000001];
void upd(int ind, int low, int high, int pos) {
  int mid = (low + high) / 2;
  if (low > high) return;
  if (ind < low || ind > high) return;
  if (ind == high && ind == low) {
    SegTree[pos] = fix[ind];
    return;
  }
  upd(ind, low, mid, 2 * pos + 1);
  upd(ind, mid + 1, high, 2 * pos + 2);
  SegTree[pos] = SegTree[2 * pos + 1] + SegTree[2 * pos + 2];
}
void upd2(int ind, int low, int high, int pos) {
  int mid = (low + high) / 2;
  if (low > high) return;
  if (ind < low || ind > high) return;
  if (ind == high && ind == low) {
    SegTree2[pos] = fixx[ind];
    return;
  }
  upd2(ind, low, mid, 2 * pos + 1);
  upd2(ind, mid + 1, high, 2 * pos + 2);
  SegTree2[pos] = SegTree2[2 * pos + 1] + SegTree2[2 * pos + 2];
}
int sum(int L, int R, int low, int high, int pos) {
  int mid = (low + high) / 2;
  if (low > high) return 0;
  if (L > high || R < low) return 0;
  if (L <= low && R >= high) return SegTree[pos];
  return sum(L, R, low, mid, 2 * pos + 1) +
         sum(L, R, mid + 1, high, 2 * pos + 2);
}
int sum2(int L, int R, int low, int high, int pos) {
  int mid = (low + high) / 2;
  if (low > high) return 0;
  if (L > high || R < low) return 0;
  if (L <= low && R >= high) return SegTree2[pos];
  return sum2(L, R, low, mid, 2 * pos + 1) +
         sum2(L, R, mid + 1, high, 2 * pos + 2);
}
void update() {
  fix[a[l] - 1] = 0;
  upd(a[l] - 1, 0, High, 0);
  Sum -= sum(a[l], High, 0, High, 0);
  Sum -= sum2(0, a[l] - 2, 0, High, 0);
  l--;
}
void update2() {
  fixx[a[r - 1] - 1] = 1;
  upd2(a[r - 1] - 1, 0, High, 0);
  Sum += sum2(0, a[r - 1] - 2, 0, High, 0);
  Sum += sum(a[r - 1], High, 0, High, 0);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    p[i].first = a[i];
    p[i].second = i;
  }
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++) {
    a[p[i].second] = i;
  }
  for (int i = 1; i <= n; i++) {
    int x = log2(a[i]);
    if ((1 << x) == a[i])
      High = max(High, a[i] - 1);
    else
      High = max(High, (1 << x + 1) - 1);
  }
  for (int i = 1; i < n; i++) {
    fix[a[i] - 1] = 1;
    upd(a[i] - 1, 0, High, 0);
    Sum += sum(a[i], High, 0, High, 0);
  }
  fixx[a[n] - 1] = 1;
  upd2(a[n] - 1, 0, High, 0);
  Sum += sum(a[n], High, 0, High, 0);
  l = n - 1, r = n;
  for (r = n; r > 1; r--) {
    while (Sum > k && l > 0) {
      update();
    }
    if (r == l) update();
    if (r > l) ans += l;
    update2();
  }
  cout << ans;
}
