Question: I am trying to create a list of integers and then scan it in order to find the minimum absolute value of the substractions of the elements of the list. I have created the list, but there is problem in the code which finds the minimum absolute value, as the result it shows is not correct. I think it is probably in the possitions of the elements of the list during the loops. Can you help me find it?

For example, when I create a list `Α = [2, 7, 5, 9, 3, 1, 2]`, the result of `min` should be 0, but it is 1.

Here is my code:

```
min=1000
for i in range (1, N-1):
    for j in range (i+1, N):
        if (abs (A [i-1] - A [j-1])<min):
            min = abs (A [i-1] - A [j-1])
print ("%d" %min)

```

Answer: 
using numpy 

```
import numpy as np
A = [2, 7, 5, 9, 3, 1, 2]
v = np.abs(np.diff(np.sort(np.array(A))))
np.min(v)

```

out : 0

Or You can use numpy only for the diff part like this :

```
v = min(abs(np.diff(sorted(A))))

```
This is what you are looking for:

```
A = [2, 7, 5, 9, 3, 1, 2]

diffs = []
for index1, i in enumerate(A):
     for index2, j in enumerate(A):
         if index1 != index2:
             diffs.append(abs(i-j))             

print(min(diffs))

```

Output:

```
0

```

**Updated** to exclude subtraction of same items