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 N = 1e5 + 2;
int tree1[4 * N], tree2[4 * N];
pair<long long, int> a[N];
int b[N];
long long n, k;
long long invs1[N], invs2[N];
int maxv;
long long totalInvs = 0;
long long crossRangeInvs = 0;
void compress() {
  sort(a + 1, a + n + 1);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (i == 1 || a[i].first != a[i - 1].first) cnt++;
    b[a[i].second] = cnt;
  }
  maxv = cnt;
}
void update(int tree[], int node, int l, int r, int ind, int val) {
  if (l == r)
    tree[node] += val;
  else {
    int ln = node << 1;
    int rn = ln + 1;
    int mid = (l + r) >> 1;
    if (ind <= mid)
      update(tree, ln, l, mid, ind, val);
    else
      update(tree, rn, mid + 1, r, ind, val);
    tree[node] = tree[ln] + tree[rn];
  }
}
int query(int tree[], int node, int l, int r, int l2, int r2) {
  if (l2 > r2) return 0;
  if (l >= l2 && r <= r2) return tree[node];
  if (l > r2 || r < l2) return 0;
  int ln = node << 1;
  int rn = ln + 1;
  int mid = (l + r) >> 1;
  int q1 = query(tree, ln, l, mid, l2, r2);
  int q2 = query(tree, rn, mid + 1, r, l2, r2);
  return q1 + q2;
}
void calculateInversions() {
  invs1[1] = invs2[n] = 0;
  update(tree1, 1, 1, n, b[1], 1);
  update(tree2, 1, 1, n, b[n], 1);
  for (int i = 2; i <= n; i++) {
    invs1[i] = query(tree1, 1, 1, n, b[i] + 1, maxv) + invs1[i - 1];
    update(tree1, 1, 1, n, b[i], 1);
  }
  for (int i = n - 1; i >= 1; i--) {
    invs2[i] = query(tree2, 1, 1, n, 1, b[i] - 1) + invs2[i + 1];
    update(tree2, 1, 1, n, b[i], 1);
  }
  totalInvs = invs1[n];
  crossRangeInvs = query(tree1, 1, 1, n, b[n] + 1, maxv);
}
void moveLeftPointer(int &l) {
  crossRangeInvs -= query(tree2, 1, 1, n, 1, b[l] - 1);
  update(tree1, 1, 1, n, b[l], -1);
  l--;
}
void moveRightPointer(int &r) {
  r--;
  crossRangeInvs += query(tree1, 1, 1, n, b[r] + 1, maxv);
  update(tree2, 1, 1, n, b[r], 1);
}
long long solve() {
  int l = n - 1, r = n;
  long long cnt = 0;
  update(tree2, 1, 1, n, b[n], 1);
  while (l > 0) {
    long long invs = invs1[l] + invs2[r] + crossRangeInvs;
    if (invs <= k) {
      cnt += l;
      if (r - l == 1) moveLeftPointer(l);
      moveRightPointer(r);
    } else
      moveLeftPointer(l);
  }
  return cnt;
}
void read() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    a[i] = {x, i};
  }
}
int main() {
  ios::sync_with_stdio(0);
  read();
  compress();
  calculateInversions();
  memset(tree1, 0, sizeof(tree1));
  memset(tree2, 0, sizeof(tree2));
  for (int i = 1; i <= n - 1; i++) update(tree1, 1, 1, n, b[i], 1);
  cout << solve() << endl;
  return 0;
}
