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;
using ll = long long;
const int N = 100010, LN = 17;
const int M = 4 * N * LN;
int t[M], L[M], R[M];
int nodes;
int build(int l, int r) {
  int i = nodes++;
  if (l == r) {
    t[i] = 0;
  } else {
    int m = (l + r) / 2;
    L[i] = build(l, m);
    R[i] = build(m + 1, r);
    t[i] = t[L[i]] + t[R[i]];
  }
  return i;
}
int add(int i, int l, int r, int p, int v) {
  int j = nodes++;
  if (l == r) {
    t[j] = t[i] + v;
  } else {
    int m = (l + r) / 2;
    if (p <= m) {
      L[j] = add(L[i], l, m, p, v);
      R[j] = R[i];
    } else {
      L[j] = L[i];
      R[j] = add(R[i], m + 1, r, p, v);
    }
    t[j] = t[L[j]] + t[R[j]];
  }
  return j;
}
int query(int i, int l, int r, int ql, int qr) {
  if (r < ql || l > qr) return 0;
  if (ql <= l && r <= qr) return t[i];
  int m = (l + r) / 2;
  return query(L[i], l, m, ql, qr) + query(R[i], m + 1, r, ql, qr);
}
vector<int> compr;
int root[N], v[N];
int n;
ll k;
int query(int l, int r, int a, int b) {
  return query(root[r], 0, n, a, b) - query(root[l - 1], 0, n, a, b);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    compr.push_back(v[i]);
  }
  sort(begin(compr), end(compr));
  compr.resize(unique(begin(compr), end(compr)) - begin(compr));
  root[0] = build(0, n);
  for (int i = 1; i <= n; i++) {
    v[i] = lower_bound(begin(compr), end(compr), v[i]) - begin(compr);
    root[i] = add(root[i - 1], 0, n, v[i], 1);
  }
  ll t = 0, ans = 0;
  for (int i = 2; i <= n; i++) {
    t += query(1, i - 1, v[i] + 1, n);
  }
  for (int l = 1, r = 2; l < n; l++) {
    if (r == l) r++;
    while (r < n && t > k) {
      t -= query(1, l, v[r] + 1, n);
      t -= query(r + 1, n, 0, v[r] - 1);
      r++;
    }
    if (t <= k) {
      ans += n - r + 1;
    }
    if (r > l + 1) {
      t += query(1, l, v[l + 1] + 1, n);
      t += query(r, n, 0, v[l + 1] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
