AT_abc419_e [ABC419E] Subarray Sum Divisibility
Description
You are given a length- $ N $ integer sequence $ A = (A_1, A_2, \ldots, A_N) $ .
Your goal is to perform the following operation repeatedly so that for every length- $ L $ contiguous subarray of $ A $ , the sum is a multiple of $ M $ .
- Choose an integer $ i $ such that $ 1 \leq i \leq N $ , and increase the value of $ A_i $ by $ 1 $ .
Find the minimum possible number of operations before achieving the goal.
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ M $ $ L $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $
Output Format
Output the answer.
Explanation/Hint
### Sample Explanation 1
By performing the operation once choosing $ i = 2 $ , twice choosing $ i = 3 $ , and once choosing $ i = 4 $ , you get $ A = (4, 3, 3, 4) $ with a total of four operations, where every length- $ 3 $ contiguous subarray sums to a multiple of $ 5 $ .
### Constraints
- $ 1 \leq N, M \leq 500 $
- $ 1 \leq L \leq N $
- $ 0 \leq A_i < M $
- All input values are integers.