trivial dp solution
Intuition\nThis question is the same as the previous question\n\n# Complexity\n- Time complexity:\nO(\sum nums)\n\n- Space complexity:\nO(\textit{max}(nums))\n\
# Intuition\nThis question is the same as [the previous question](https://leetcode.com/problems/find-the-count-of-monotonic-pairs-i/description/)\n\n# Complexity\n- Time complexity:\n$$O(\\sum nums)$$\n\n- Space complexity:\n$$O(\\textit{max}(nums))$$\n\n# Code\n```\nimpl Solution {\n    pub fn count_of_pairs(nums: Vec<i32>) -> i32 {\n        let MOD=1000000007usize;\n        let mut prev=nums[0] as usize;\n        let mut dp=vec![1; prev+1];\n        for &n in &nums[1..]{\n            let n=n as usize;\n            for i in 1..dp.len(){\n                dp[i]+=dp[i-1];\n                dp[i]%=MOD;\n            }\n            let mut cur=vec![0; n+1];\n            if prev>=n{\n                cur.clone_from_slice(&dp[..=n]);\n            }else{\n                cur[n-prev..=n].clone_from_slice(&dp);\n            }\n\n            prev=n;\n            dp=cur;\n        }\n        let mut res=0;\n        for n in dp{\n            res+=n;\n            res%=MOD;\n        }\n        res as i32\n    }\n}\n```
['Dynamic Programming', 'Prefix Sum', 'Rust']