Time limit: 1s
Memory limit: 64MB
Input:
Output:
Task
You are given an array of elements.
The cost of a continuous subarray is defined as .
You need to calculate modulo .
Input data
The first line contains and the second line contains values representing the array .
Output data
A single number, the required sum modulo .
Constraints and clarifications
- For points, .
- For an additional points, .
Example 1
stdin
4
2 1 3 2
stdout
28
Explanation
Example 2
stdin
8
7 45 12 4398 183 13261 423871 321
stdout
235372600