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;
struct Node;
typedef Node* Tree;
const int N = 100000;
int n, a[N];
long long limit;
Tree null;
struct Node {
  int count;
  Tree left, right;
  Node(int count, Tree left, Tree right)
      : count(count), left(left), right(right) {}
  Tree insert(int l, int r, int k) {
    if (k < l || r <= k) {
      return this;
    }
    if (l == k && k + 1 == r) {
      return new Node(count + 1, null, null);
    }
    int m = (l + r) >> 1;
    return new Node(count + 1, left->insert(l, m, k), right->insert(m, r, k));
  }
  int query(int l, int r, int a, int b) {
    if (b <= l || r <= a) {
      return 0;
    }
    if (a <= l && r <= b) {
      return count;
    }
    int m = (l + r) >> 1;
    return left->query(l, m, a, b) + right->query(m, r, a, b);
  }
};
Tree prefix[N + 1], suffix[N + 1];
int main() {
  null = new Node(0, NULL, NULL);
  null->left = null->right = null;
  cin >> n >> limit;
  vector<int> values;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    values.push_back(a[i]);
  }
  sort(values.begin(), values.end());
  values.erase(unique(values.begin(), values.end()), values.end());
  for (int i = 0; i < n; ++i) {
    a[i] = lower_bound(values.begin(), values.end(), a[i]) - values.begin();
  }
  prefix[0] = suffix[0] = null;
  for (int i = 0; i < n; ++i) {
    prefix[i + 1] = prefix[i]->insert(0, n, a[i]);
    suffix[i + 1] = suffix[i]->insert(0, n, a[n - 1 - i]);
  }
  long long current = 0;
  for (int i = 0; i < n; ++i) {
    current += prefix[i]->query(0, n, a[i] + 1, n);
  }
  current -= suffix[n - 1]->query(0, n, 0, a[0]);
  long long result = (long long)n * (n - 1) / 2;
  limit++;
  for (int i = 0, j = 1; i + 1 < n; ++i) {
    current += prefix[i]->query(0, n, a[i] + 1, n);
    current += suffix[n - j]->query(0, n, 0, a[i]);
    while (j + 1 < n) {
      long long tmp = current;
      tmp -= prefix[i + 1]->query(0, n, a[j] + 1, n);
      tmp -= suffix[n - j - 1]->query(0, n, 0, a[j]);
      if (tmp < limit) {
        break;
      }
      current = tmp;
      j++;
    }
    if (current >= limit) {
      result -= j - i;
    }
    if (j == i + 1) {
      current -= prefix[i + 1]->query(0, n, a[j] + 1, n);
      current -= suffix[n - j - 1]->query(0, n, 0, a[j]);
      j++;
    }
  }
  cout << result << endl;
  return 0;
}
