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>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-3;
const int inf = 1000000000;
const long long linf = 1000000000000000000LL;
template <class T>
inline T sqr(T x) {
  return x * x;
}
struct segtree {
  int tree[410000];
  void clear(int a, int b, int k) {
    tree[k] = 0;
    if (b == a + 1) return;
    int c = (a + b) / 2;
    clear(a, c, k * 2 + 1);
    clear(c, b, k * 2 + 2);
  }
  void add(int p, int v, int a, int b, int k) {
    tree[k] += v;
    if (b == a + 1) {
      return;
    }
    int c = (a + b) / 2;
    if (p < c)
      add(p, v, a, c, k * 2 + 1);
    else
      add(p, v, c, b, k * 2 + 2);
  }
  int getsum(int l, int r, int a, int b, int k) {
    if (r <= l || r <= a || l >= b) return 0;
    if (l <= a && r >= b) return tree[k];
    int c = (a + b) / 2;
    return getsum(l, r, a, c, k * 2 + 1) + getsum(l, r, c, b, k * 2 + 2);
  }
};
int src0[110000];
int src[110000];
int n;
long long K;
void gen(int nn) {
  n = nn;
  for (int i = 0; i < (n); ++i) {
    src0[i] = rand() % 10;
  }
  K = rand() % (n * (n - 1) / 2 + 1);
}
int vals[110000];
long long pref[110000];
long long suff[110000];
segtree tmp;
segtree tre1, tre2;
long long clever() {
  for (int i = 0; i < (n); ++i) {
    src[i] = src0[i];
    vals[i] = src0[i];
  }
  sort(vals, vals + n);
  int c = unique(vals, vals + n) - vals;
  for (int i = 0; i < (n); ++i) {
    src[i] = lower_bound(vals, vals + c, src[i]) - vals;
  }
  tmp.clear(0, c, 0);
  for (int i = 0; i < (n); ++i) {
    pref[i + 1] = pref[i] + tmp.getsum(src[i] + 1, c, 0, c, 0);
    tmp.add(src[i], 1, 0, c, 0);
  }
  tmp.clear(0, c, 0);
  for (int i = n - 1; i >= 0; --i) {
    suff[i] = suff[i + 1] + tmp.getsum(0, src[i], 0, c, 0);
    tmp.add(src[i], 1, 0, c, 0);
  }
  long long res = 0;
  tre1.clear(0, c, 0);
  tre2.clear(0, c, 0);
  for (int i = 0; i < (n); ++i) tre2.add(src[i], 1, 0, c, 0);
  long long cur = 0;
  int a = 0;
  for (int b = 1; b < n; ++b) {
    cur -= tre1.getsum(src[b - 1] + 1, c, 0, c, 0);
    tre2.add(src[b - 1], -1, 0, c, 0);
    while (a < b && cur + pref[a] + suff[b] <= K) {
      cur += tre2.getsum(0, src[a], 0, c, 0);
      tre1.add(src[a], 1, 0, c, 0);
      ++a;
    }
    if (a) {
      res += a - 1;
      if (cur + pref[a] + suff[b] <= K) ++res;
    }
  }
  return res;
}
long long brute() {
  int r = 0;
  for (int a = 1; a < n; ++a) {
    for (int b = a; b < n; ++b) {
      vector<int> v(src0, src0 + a);
      v.insert(v.end(), src0 + b, src0 + n);
      int c = 0;
      for (int j = 0; j < (((int)(v).size())); ++j)
        for (int i = 0; i < (j); ++i)
          if (v[j] < v[i]) ++c;
      if (c <= K) ++r;
    }
  }
  return r;
}
void stress() {
  for (int nn = 1; nn <= 50; ++nn) {
    for (int qqq = 0; qqq < (10000); ++qqq) {
      gen(nn);
      long long b = brute();
      long long r = clever();
      if (b != r) {
        cout << "failed " << nn << ' ' << qqq << endl << endl;
        cout << n << ' ' << K << endl;
        for (int i = 0; i < (n); ++i) cout << src0[i] << ' ';
        exit(123);
      }
    }
  }
  cout << "passed" << endl;
}
int main() {
  cin >> n >> K;
  for (int i = 0; i < (n); ++i) {
    scanf("%d", src0 + i);
  }
  cout << clever();
  return 0;
}
