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 int Pow(long long int a, long long int b, long long int md,
                  long long int ans = 1) {
  for (; b; b >>= 1, a = a * a % md)
    if (b & 1) ans = ans * a % md;
  return ans % md;
}
const long long int MAXN = 2e5 + 10;
const long long int INF = 8e18;
const long long int MOD = 1e9 + 7;
long long int A[MAXN], fen[2][MAXN], n, k, ptr = 1, inv = 0, ans = 0, cnt = 0;
vector<long long int> compress;
void update(long long int id, long long int pos, long long int val) {
  for (pos++; pos < MAXN; pos += pos & -pos) {
    fen[id][pos] += val;
  }
}
long long int get(long long int id, long long int pos, long long int res = 0) {
  for (pos++; pos; pos -= pos & -pos) {
    res += fen[id][pos];
  }
  return res;
}
int main() {
  scanf("%lld%lld", &n, &k);
  for (long long int i = 1; i <= n; i++)
    scanf("%lld", &A[i]), compress.push_back(A[i]);
  sort((compress).begin(), (compress).end());
  compress.resize(unique((compress).begin(), (compress).end()) -
                  compress.begin());
  for (long long int i = 1; i <= n; i++) {
    A[i] = lower_bound((compress).begin(), (compress).end(), A[i]) -
           compress.begin() + 1;
  }
  for (long long int i = n; i; i--) {
    inv += get(1, A[i] - 1);
    if (i > 1) update(1, A[i], 1);
  }
  if (inv <= k) return !printf("%lld\n", n * (n - 1) / 2);
  for (long long int i = 1; i < n; i++) {
    update(0, A[i], 1);
    while (cnt + k < inv && ptr < n - 1) {
      ptr++;
      update(1, A[ptr], -1);
      cnt += get(0, MAXN - 2) - get(0, A[ptr]) + get(1, A[ptr] - 1);
    }
    if (cnt + k < inv) break;
    cnt -= get(1, A[i + 1] - 1) + get(0, MAXN - 2) - get(0, A[i + 1]);
    ans += n - ptr;
  }
  printf("%lld\n", ans);
  return 0;
}
