A sequence of integers a1,a2,…,an is called happy if every element except the first and the last one equals the sum of its two neighbours, that is, aj=aj−1+aj+1 for every j with 2≤j≤n−1.
You are given a sequence of integers. In one step you can choose one element of the sequence and increase or decrease it by one. Find the minimum number of steps needed to obtain a happy sequence.