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;
int t1[400000];
int t2[400000];
void build(const vector<int> &a, int v, int tl, int tr, int t[]) {
  if (tl == tr)
    t[v] = a[tl];
  else {
    int tm = (tl + tr) / 2;
    build(a, v * 2, tl, tm, t);
    build(a, v * 2 + 1, tm + 1, tr, t);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
int sum(int v, int tl, int tr, int l, int r, int t[]) {
  if (l > r) return 0;
  if (l == tl && r == tr) return t[v];
  int tm = (tl + tr) / 2;
  return sum(v * 2, tl, tm, l, min(r, tm), t) +
         sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, t);
}
void update(int v, int tl, int tr, int pos, int new_val, int t[]) {
  if (tl == tr)
    t[v] = new_val;
  else {
    int tm = (tl + tr) / 2;
    if (pos <= tm)
      update(v * 2, tl, tm, pos, new_val, t);
    else
      update(v * 2 + 1, tm + 1, tr, pos, new_val, t);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
long long solve(long long n, long long k, vector<pair<int, int> > a) {
  sort(a.begin(), a.end());
  vector<int> v(n);
  int cur = 0;
  v[a[0].second] = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i].first != a[i - 1].first) ++cur;
    v[a[i].second] = cur;
  }
  vector<int> was(n + 1, 0);
  vector<int> was_b(n + 1, 0);
  build(was_b, 1, 0, n, t2);
  build(was, 1, 0, n, t1);
  long long cursum = 0;
  for (int i = n - 1; i >= 1; --i) {
    ++was[v[i]];
    update(1, 0, n, v[i], was[v[i]], t1);
    cursum += sum(1, 0, n, 0, v[i] - 1, t1);
  }
  long long res = 0;
  cur = 1;
  for (int i = 0; i + 1 < n; ++i) {
    was_b[v[i]]++;
    update(1, 0, n, v[i], was_b[v[i]], t2);
    cursum += sum(1, 0, n, 0, v[i] - 1, t1);
    cursum += sum(1, 0, n, v[i] + 1, n, t2);
    while ((cursum > k || cur == i) && cur < n) {
      was[v[cur]]--;
      update(1, 0, n, v[cur], was[v[cur]], t1);
      cursum -= sum(1, 0, n, v[cur] + 1, n, t2);
      cursum -= sum(1, 0, n, 0, v[cur] - 1, t1);
      ++cur;
    }
    if (cur >= n) break;
    res += n - cur;
  }
  return res;
}
long long solve_stress(int n, int k, vector<pair<int, int> > a) {
  int res = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      int cnt = 0;
      vector<int> b;
      for (int i1 = 0; i1 <= i; ++i1) b.push_back(a[i].first);
      for (int j1 = j; j1 < n; ++j1) b.push_back(a[j].first);
      for (int l = 0; l < b.size(); ++l)
        for (int l1 = l + 1; l1 < b.size(); ++l1)
          if (b[l] > b[l1]) ++cnt;
      if (cnt <= k) ++res;
    }
  return res;
}
int main() {
  long long n, k;
  cin >> n >> k;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  cout << solve(n, k, a) << endl;
  return 0;
}
