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 long long int MAX = 9187201950435737471;
const double pi = acos(-1);
long double eps = 1e-8;
const int N = 1000009;
const long long mod = 1000000007;
const int M = 2147483647;
const int lg = 101;
long long n, Index, Left, Right, Seg1[N * 4], Seg2[N * 4], A[N], k;
pair<int, int> tem[N];
void upd1(int idx, int st, int ed, int val) {
  if (st == ed) {
    Seg1[idx] += val;
    return;
  }
  int mid = ((st + ed) / 2);
  if (Index <= mid)
    upd1((idx * 2), st, mid, val);
  else
    upd1((idx * 2 + 1), mid + 1, ed, val);
  Seg1[idx] = Seg1[(idx * 2)] + Seg1[(idx * 2 + 1)];
}
void upd2(int idx, int st, int ed, int val) {
  if (st == ed) {
    Seg2[idx] += val;
    return;
  }
  int mid = ((st + ed) / 2);
  if (Index <= mid)
    upd2((idx * 2), st, mid, val);
  else
    upd2((idx * 2 + 1), mid + 1, ed, val);
  Seg2[idx] = Seg2[(idx * 2)] + Seg2[(idx * 2 + 1)];
}
long long int Q(int idx, int st, int ed, int type) {
  if (Left > ed || Right < st) return 0;
  if (Left <= st && ed <= Right) {
    if (type == 1)
      return Seg1[idx];
    else if (type == 2)
      return Seg2[idx];
  }
  int mid = ((st + ed) / 2);
  return Q((idx * 2), st, mid, type) + Q((idx * 2 + 1), mid + 1, ed, type);
}
long long int TOT, Ans;
void proc(int x, int type) {
  Left = x + 1, Right = n;
  long long int tem = Q(1, 1, n, 1) * type;
  Left = 1, Right = x - 1;
  tem = tem + Q(1, 1, n, 2) * type;
  TOT += tem;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    tem[i] = {x, i};
  }
  sort(tem + 1, tem + n + 1);
  int cnt = 2;
  A[tem[1].second] = 1;
  for (int i = 2; i <= n; i++) {
    if (tem[i].first == tem[i - 1].first)
      A[tem[i].second] = A[tem[i - 1].second];
    else
      A[tem[i].second] = cnt++;
  }
  for (int i = 1; i <= n; i++) {
    Index = A[i];
    upd1(1, 1, n, 1);
  }
  for (int i = 1; i <= n; i++) {
    Right = A[i] - 1;
    TOT += Q(1, 1, n, 1);
    Index = A[i];
    upd1(1, 1, n, -1);
  }
  for (int i = 2; i <= n; i++) {
    Index = A[i];
    upd2(1, 1, n, 1);
  }
  Index = A[1];
  upd1(1, 1, n, 1);
  long long int K = TOT;
  long long int i = 1, j = 2;
  while (i <= n) {
    bool fd = false;
    if (i == j) {
      Index = A[j];
      upd2(1, 1, n, -1);
      if (j < n)
        j++;
      else
        break;
      continue;
    }
    if (i == j - 1) TOT = K;
    if (TOT <= k) {
      fd = true;
      Ans += n - j + 1;
      i++;
      if (i != j) {
        proc(A[i], 1);
        Index = A[i];
        upd1(1, 1, n, 1);
      }
    } else {
      if (j < n) {
        Index = A[j];
        upd2(1, 1, n, -1);
        proc(A[j], -1);
        j++;
      } else {
        i++;
        proc(A[i], 1);
        Index = A[i];
        upd1(1, 1, n, 1);
      }
    }
  }
  cout << Ans;
  return 0;
}
