Adding the adjacent difference modulus values of removed element . Removing adjacent difference modulus value after removing element
temp = ( abs ( arr [ i ] - arr [ i + 1 ] ) + abs ( arr [ i ] - arr [ i - 1 ] ) - abs ( arr [ i - 1 ] - arr [ i + 1 ] ) ) NEW_LINE elif ( i == 0 ) : NEW_LINE value = value + abs ( arr [ i ] - arr [ i + 1 ] ) NEW_LINE temp = abs ( arr [ i ] - arr [ i + 1 ] ) NEW_LINE else : NEW_LINE temp = abs ( arr [ i ] - arr [ i - 1 ] ) NEW_LINE maximum = max ( maximum , temp ) NEW_LINE