Given an array, A, having N integers, an increasing subsequence of this array of length k is a set of k indices i1,i2,...ik, such that 1≤i1<i2<...ik≤N and A[i1]<A[i2]<A[i3]<...<A[ik].
Energy of a subsequence is defined as sum of difference of consecutive numbers in the subsequence. For a given integer k, you need to find out the maximum value of energy among energies of all increasing subsequences of length k.
Hint: Among all increasing sequences of length k ending at an index, find the sequence with minimum value of starting point
Input:
First line consists of two space separated integer denoting N and k.
Second line consists of N space separated integers denoting the array A.
Output:
Print the maximum value of energy among energies of all increasing subsequences of length k.
If there are no increasing subsequences of length k in the array, print "-1" (without quotes")
Input Constraints:
1≤k×N≤106
2≤k≤N
1≤A[i]≤109
All increasing subsequences of length 2 and their respective energies are given below:
1 2, energy = 1
1 3, energy = 2
1 4, energy = 3
2 3, energy = 1
2 4, energy = 2
3 4, energy = 1
So clearly the maximum value of energy among all energies of all increasing subsequences of length 2 is 3.