Why finding the difference between the adjacent elements of the array to find the maximum difference?
Suppose that the original array is $a_1,\ldots,a_n$. The new array is $b_i = a_{i+1} - a_i$ for $1 \leq i \leq n-1$. Note that
$$
a_j - a_i = b_i + \cdots + b_{j-1}.
$$
Hence
$$
\max_{\substack{i &lt; j \\ a_i &lt; a_j}} |a_j-a_i| = \max_{i&lt;j} (a_j-a_i) = \max_{i&lt;j} b_i + \cdots + b_{j-1}.
$$