In this Kata, we define an arithmetic progression as a series of integers in which the differences between adjacent numbers are the same. You will be given an array of ints of `length > 2` and your task will be to convert it into an arithmetic progression by the following rule:
```Haskell
For each element there are exactly three options: an element can be decreased by 1, an element can be increased by 1 
or it can be left unchanged.
```
Return the minimum number of changes needed to convert the array to an arithmetic progression. If not possible, return `-1`.
```Haskell
For example: 
solve([1,1,3,5,6,5]) == 4 because [1,1,3,5,6,5] can be changed to [1,2,3,4,5,6] by making 4 changes.
solve([2,1,2]) == 1 because it can be changed to [2,2,2]
solve([1,2,3]) == 0  because it is already a progression, and no changes are needed.
solve([1,1,10) == -1 because it's impossible.
solve([5,6,5,3,1,1]) == 4. It becomes [6,5,4,3,2,1]
```
More examples in the test cases. Good luck!
def solve(ls):
    result = [ls[each]-ls[each-1] for each in range(1, len(ls))] 
    gap = round(sum(result)/len(result))
    tries = [ls[0]+1, ls[0], ls[0]-1] 
    answer = []
    
    while True:
        count = 0    
        copy_ls = ls[:]
        
        copy_ls[0] = tries.pop(0)
        if copy_ls[0] != ls[0]:
            count += 1
        
        for each in range(len(ls)-1):
            sub_gap = copy_ls[each+1] - copy_ls[each]
            if sub_gap < gap:
                copy_ls[each+1] += 1
                count += 1
            elif sub_gap > gap:
                copy_ls[each+1] -= 1
                count += 1
        
        result = [copy_ls[each]-copy_ls[each-1] for each in range(1, len(ls))]
        
        if len(set(result)) == 1:
            answer.append(count)
        if len(tries) == 0:
            if len(answer) == 0:
                return -1
            else:
                answer.sort()
                return answer[0]
def solve(ls):
    result = [ls[each]-ls[each-1] for each in range(1, len(ls))] 
    gap = round(sum(result)/len(result))
    tries = [ls[0]+1, ls[0], ls[0]-1] 
    answer = []
    
    while True:
        count = 0    
        copy_ls = ls[:]
        
        copy_ls[0] = tries.pop(0)
        if copy_ls[0] != ls[0]:
            count += 1
        
        for each in range(len(ls)-1):
            sub_gap = copy_ls[each+1] - copy_ls[each]
            if sub_gap < gap:
                copy_ls[each+1] += 1
                count += 1
            elif sub_gap > gap:
                copy_ls[each+1] -= 1
                count += 1
        
        result = [copy_ls[each]-copy_ls[each-1] for each in range(1, len(ls))]
        
        if len(set(result)) == 1:
            answer.append(count)
        if len(tries) == 0:
            if len(answer) == 0:
                return -1
            else:
                answer.sort()
                return answer[0]