In this challenge, you will be given an array and must determine an array . There is a special rule: For all , . That is, can be any number you choose such that . Your task is to select a series of given such that the sum of the absolute difference of consecutive pairs of is maximized. This will be the array's cost, and will be represented by the variable below.
The equation can be written:
For example, if the array , we know that , , and . Arrays meeting those guidelines are: