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;
const int MAX_A = 1e9 + 10, MAX_N = 1e5 + 10;
struct BIT {
  vector<int> ft;
  BIT(int N_) { ft.resize(N_ + 1, 0); }
  void update(int idx, const int& val) {
    while (idx < ft.size()) {
      ft[idx] += val;
      idx += (idx & -idx);
    }
  }
  int get(int idx) {
    int sum = 0;
    while (idx) {
      sum += ft[idx];
      idx -= (idx & -idx);
    }
    return sum;
  }
};
int n, a[MAX_N], l, r, ct = 1;
long long k, ans, inv, sum;
set<int> st;
map<int, int> mp;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) scanf("%d", a + i), st.insert(a[i]);
  for (set<int>::iterator it = st.begin(); it != st.end(); ++it) mp[*it] = ct++;
  for (int i = 1; i <= n; i++) a[i] = mp[a[i]];
  BIT ft1(ct), ft2(ct);
  l = 1, r = n + 1;
  ft1.update(a[1], 1);
  while (l + 1 != r) {
    sum = (a[r - 1] < a[1]);
    sum += ft2.get(a[r - 1] - 1);
    if (inv + sum > k) break;
    ft2.update(a[--r], 1);
    inv += sum;
  }
  if (r == n + 1) {
    cout << 0 << endl;
    return (0);
  }
  if (l + 1 == r) {
    cout << 1LL * n * (n - 1) / 2 << endl;
    return (0);
  }
  ans = n - r + 1;
  int pib = r;
  while (l <= pib and l < n) {
    l++;
    inv += ft1.get(ct) - ft1.get(a[l]);
    inv += ft2.get(a[l] - 1);
    ft1.update(a[l], 1);
    if (inv <= k) {
      ans += n - r + 1;
    } else {
      while (r < n) {
        inv -= ft1.get(ct) - ft1.get(a[r]);
        inv -= ft2.get(a[r] - 1);
        ft2.update(a[r], -1);
        r++;
        if (inv <= k) break;
      }
      if (inv <= k) {
        ans += n - r + 1;
      }
    }
  }
  cout << ans << endl;
  return (0);
}
