arr = [3,1,1,4,5,9]
arr.sort()
M = 3
N = 6
li = 0
big = 0
answer = 0

for i in range(M):
    li += arr[i]
    
for i in range(M,N):
    big += arr[i]

answer = big - li
print(answer)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: