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<stdio.h>
int left[262144],right[262144];
int num=0;
int val[262144];
long long ans=0;
int n,l;
int sl[262144],sr[262144];
void dec()
{
	int now;
	for(now=num-1;now>0;now--)
	{
		if(val[now]!=val[now-1])
		{
			break;
		}
	}
	int d=num-now;
	int v=val[now];
	long long s=0;
	for(int i=now;i<num;i++)
	{
		ans+=(long long)left[i]*right[i];
		if(i-l+1>=now)
		{
			s+=left[i-l+1];
		}
		ans+=s*right[i];
	}
	if(d<l)
	{
		num=now;
		while(num)
		{
			dec();
		}
		return;
	}
	int dd=d/l;
	for(int i=0;i<=dd;i++)
	{
		sl[i]=0;
		sr[i]=0;
	}
	for(int i=now;i<num;i++)
	{
		sl[(i-now+1)/l]+=right[i];
		sr[(num-i)/l]+=left[i];
	}
	num=now+dd;
	for(int i=1;i<=dd;i++)
	{
		right[now+i-1]=sl[i];
		left[num-i]=sr[i];
	}
	s=0;
	for(int i=now;i<num;i++)
	{
		val[i]=v+1;
		ans-=(long long)left[i]*right[i];
		if(i-l+1>=now)
		{
			s+=left[i-l+1];
		}
		ans-=s*right[i];
	}
}
int main()
{
	scanf("%d%d",&n,&l);
	while(n--)
	{
		int a;
		scanf("%d",&a);
		while(num>0)
		{
			if(val[num-1]>=a)
			{
				break;
			}
			dec();
		}
		left[num]=1;
		right[num]=1;
		val[num]=a;
		num++;
	}
	while(num)
	{
		dec();
	}
	printf("%lld\n",ans);
	return 0;
}