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 MAXN = 1000 * 1000 + 10;
long long a[MAXN];
vector<long long> seg[MAXN * 4];
long long n, k;
void merge(int v, const vector<long long> &a, const vector<long long> &b) {
  int i = 0, j = 0;
  while (i < (int)a.size() || j < (int)b.size()) {
    if (j >= (int)b.size() || (i < (int)a.size() && a[i] < b[j]))
      seg[v].push_back(a[i]), i++;
    else
      seg[v].push_back(b[j]), j++;
  }
}
void build(int v, int s, int e) {
  if (e - s <= 1) {
    seg[v].push_back(a[s]);
    return;
  }
  int m = (s + e) / 2;
  build(v * 2, s, m);
  build(v * 2 + 1, m, e);
  merge(v, seg[v * 2], seg[v * 2 + 1]);
}
int get(int l, int r, int x, int ty, int v, int s, int e) {
  if (r <= s || e <= l) return 0;
  if (l <= s && e <= r) {
    int k = 0;
    if (ty == 0)
      k = lower_bound(seg[v].begin(), seg[v].end(), x) - seg[v].begin();
    else
      k = (int)seg[v].size() -
          (upper_bound(seg[v].begin(), seg[v].end(), x) - seg[v].begin());
    return k;
  }
  int m = (s + e) / 2;
  return get(l, r, x, ty, v * 2, s, m) + get(l, r, x, ty, v * 2 + 1, m, e);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  build(1, 0, n);
  long long all = 0;
  for (int i = 0; i < n; i++) all += get(0, i, a[i], 1, 1, 0, n);
  if (all <= k) {
    cout << n * (n - 1) / 2 << endl;
    return 0;
  }
  long long i = 0, j = 0, now = 0;
  while (j < n && now < all - k) {
    long long t =
        (i ? get(0, i, a[j], 1, 1, 0, n) : 0) + get(j, n, a[j], 0, 1, 0, n);
    now += t;
    j++;
  }
  long long ans = 0;
  while (i < n - 1) {
    long long t =
        (i ? get(0, i, a[i], 1, 1, 0, n) : 0) + get(j, n, a[i], 0, 1, 0, n);
    now -= t;
    i++;
    while (j < n && now < all - k) {
      long long t2 =
          (i ? get(0, i, a[j], 1, 1, 0, n) : 0) + get(j, n, a[j], 0, 1, 0, n);
      now += t2;
      j++;
    }
    if (now >= all - k) ans += (n - j);
  }
  cout << ans << endl;
  return 0;
}
