values. Count its subsequences that have at least three elements and in which every two neighbouring elements differ by the same amount.
A subsequence is what remains after crossing out some elements of the array (possibly none) while keeping the rest in order. Subsequences built from different positions count separately, even if their values are the same.
For example, [9, 6, 3] and [2, 2, 2, 2] fit, while [1, 2, 4] does not.values=[1, 2, 3, 4] → 3
The fitting ones are [1, 2, 3], [2, 3, 4] and [1, 2, 3, 4].
values=[5, 5, 5, 5] → 5
With a step of 0 every subsequence fits: four ways to choose three positions and one way to choose all four.
values=[3, 1, -1, 4, -3] → 3
values=[1, 2, 3, 4]
3
Run checks the first 3 tests in your browser. Submit checks all 167 tests on the server, hidden ones included.