An unknown array consists of integers. The -summary of that array is obtained by dividing the array into segments of length and summing up the elements in each segment. If is not divisible by , the last segment of the division will have less than elements.
In other words, the -summary is an array where the elements are, respectively: , , and so on, where the last sum that contains can have less than summands. For example, the -summary of an array of elements has elements (sum of elements 1.-5., sum of elements 6.-10., sum of elements 11.-13.).
It is clear that we cannot reconstruct the elements of the original array from the -summary, but that might be possible if we knew several -summaries for different s. Write a program that will, given length and set , predict how many elements of the original array we would be able to uniquely determine if we knew all the -summaries of the array. (It is not difficult to show that the number of reconstructed elements is independent of the content of the summaries.)
Input Specification
The first line contains the integers and , the array length and the number of -summaries.
The second line contains distinct integers from the task.
Output Specification
You must output the required number of reconstructed elements.
Scoring
In test cases worth of total points, it will hold .
Sample Input 1
3 1
2
Sample Output 1
1
Explanation for Sample Output 1
We can determine one element: .
Sample Input 2
6 2
2 3
Sample Output 2
2
Explanation for Sample Output 2
We can determine and .
Sample Input 3
123456789 3
5 6 9
Sample Output 3
10973937
Comments