Problem Statement
Captain Ascending has discovered an ancient treasure map that reveals hidden fortunes along a mystical coastline.
The map is represented by an array A of length N, where each element A[i] indicates the treasure value (which may be negative or positive) at that location.
To unlock the ultimate riches, the captain believes his journey must be divided into segments in which the sum of treasures in each segment (called its "beauty") strictly increases as he moves from one segment to the next. The beauty of a range [L, R] in the array A is defined as the sum of the elements from A[L] to A[R].
The captain wishes to partition the array A into non-intersecting, contiguous subarrays such that, when each subarray is replaced by its beauty, the resulting sequence forms a strictly increasing progression.
Find the total number of ways to partition the array A into contiguous subarrays so that the sequence of beauties is strictly increasing. Since the answer can be very large, return it modulo 10^9 + 7.
Input Format
- The first line contains an integer,
N, denoting the number of elements inA. - Each of the
Nsubsequent lines (where 0 <= i < N) contains an integer describingA[i].
Constraints
1 <= N <= 1000-10^9 <= A[i] <= 10^9
Sample Test Cases
Case 1
- Input:
212
- Output:
2
- Explanation:
- For the array
[1][2], there are two valid partitions:- Single segment partition:
- Partition:
[1][2] - Beauty: 3
- With only one segment, the condition is automatically satisfied.
- Partition:
- Two segment partition:
- Partition:
[1]and[2] - Beauties: 1 and 2, which is strictly increasing (since 1 < 2).
- Partition:
- Single segment partition:
- Thus, the total number of valid partitions is 2.
- For the array







