For a sequence S of positive integers and positive integers k and l, S is said to belong to level (k,l) when one of the following conditions is satisfied:

* The length of S is 1, and its only element is k.
* There exist sequences T_1,T_2,...,T_m (m \geq l) belonging to level (k-1,l) such that the concatenation of T_1,T_2,...,T_m in this order coincides with S.



Note that the second condition has no effect when k=1, that is, a sequence belongs to level (1,l) only if the first condition is satisfied.

Given are a sequence of positive integers A_1,A_2,...,A_N and a positive integer L. Find the number of subsequences A_i,A_{i+1},...,A_j (1 \leq i \leq j \leq N) that satisfy the following condition:

* There exists a positive integer K such that the sequence A_i,A_{i+1},...,A_j belongs to level (K,L).

Constraints

* 1 \leq N \leq 2 \times 10^5
* 2 \leq L \leq N
* 1 \leq A_i \leq 10^9

Input

Input is given from Standard Input in the following format:


N L
A_1 A_2 ... A_N


Output

Print the number of subsequences A_i,A_{i+1},...,A_j (1 \leq i \leq j \leq N) that satisfy the condition.

Examples

Input

9 3
2 1 1 1 1 1 1 2 3


Output

22


Input

9 2
2 1 1 1 1 1 1 2 3


Output

41


Input

15 3
4 3 2 1 1 1 2 3 2 2 1 1 1 2 2


Output

31
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long ans;
int n,L;
int st[200005],top,vl[200005],vr[200005];
int sl[200005],sr[200005];
void pop(){
	int len=1,v=st[top];
	while(st[top-1]==v)top--,len++;
	top--;
	if(len<L){
		while(top)pop();
		return;
	}
	int w=len/L;
	sl[0]=0;
	for(int i=1;i<=len;i++)sl[i]=sl[i-1]+vl[i+top];
	sr[0]=0;
	for(int i=1;i<=len;i++)sr[i]=sr[i-1]+vr[i+top];
	for(int i=L;i<=len;i++)ans+=1ll*sl[i-L+1]*vr[i+top];
	for(int i=1;i<=w;i++){
		vl[top+i]=sl[len-L*(w-i+1)+1]-sl[max(len-L*(w-i+2)+1,0)];
		vr[top+i]=sr[min(L*(i+1)-1,len)]-sr[L*i-1];
	}
	for(int i=L,s=0;i<=w;i++)s+=vl[top+i-L+1],ans-=1ll*s*vr[top+i];
	for(int i=1;i<=w;i++)st[++top]=v+1;
}
int main(){
	scanf("%d%d",&n,&L);
	ans=n;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		while(top&&st[top]<x)pop();
		st[++top]=x;
		vl[top]=vr[top]=1;
		/*
		for(int i=1;i<=top;i++)printf("%d ",st[i]); puts("");
		for(int i=1;i<=top;i++)printf("%d ",vl[i]); puts("");
		for(int i=1;i<=top;i++)printf("%d ",vr[i]); puts("");
		*/
	}
	while(top)pop();
	printf("%lld\n",ans);
}