You are given an integer array nums.
Alice plays a game where she chooses an integer k > 1 and a contiguous subarray of nums defined by indices l and r where nums.length.
For every element nums[i] in the chosen subarray from index l to r:
If nums[i] is divisible by k, its value is added to Alice’s score.
If nums[i] is not divisible by k, its value is added to Bob’s score.
The score difference is defined as Alice’s score minus Bob’s score.
Alice wants to maximize the score difference. If there are multiple choices of k that achieve the maximum score difference, she chooses the minimum such k.
Return the product of the maximum score difference and the chosen value of k. Since the result can be large, return it modulo 109 + 7.
Constraints:
nums.length
nums[i]
You are given an integer array nums.
Alice plays a game where she chooses an integer k > 1 and a contiguous subarray of nums defined by indices l and r where nums.length.
For every element nums[i] in the chosen subarray from index l to r:
If nums[i] is divisible by k, its value is added to Alice’s score.
If nums[i] is not divisible by k, its value is added to Bob’s score.
The score difference is defined as Alice’s score minus Bob’s score.
Alice wants to maximize the score difference. If there are multiple choices of k that achieve the maximum score difference, she chooses the minimum such k.
Return the product of the maximum score difference and the chosen value of k. Since the result can be large, return it modulo 109 + 7.
Constraints:
nums.length
nums[i]