#Given array of integers, find the maximal possible sum of some of its k consecutive elements.

#Example

#For inputArray = [2, 3, 5, 1, 6] and k = 2, the output should be
#arrayMaxConsecutiveSum(inputArray, k) = 8.
#All possible sums of 2 consecutive elements are:

#2 + 3 = 5;
#3 + 5 = 8;
#5 + 1 = 6;
#1 + 6 = 7.
#Thus, the answer is 8.

def arrayMaxConsecutiveSum(inputArray, k):

	#sumas = len(inputArray) - k + 1

	#return max([sum(inputArray[i:(i+k)]) for i in range(sumas)])

	#BETTER!!!!!!!
	first = sum(inputArray[0:k])
	maximo = first

	for i in range(k,len(inputArray)):
		#Just add the last item and erase the first one
		first = first - inputArray[i-k] + inputArray[i]
		if first > maximo:
			maximo = first
	return maximo