<gh_stars>1-10
# program to compute the summation of the absolute difference of all distinct pairs in an given array 
# (non-decreasing order).
def sum_distinct_pairs(arr):
    result = 0
    i = 0
    while i<len(arr):
        result+=i*arr[i]-(len(arr)-i-1)*arr[i]
        i+=1
    return result
print(sum_distinct_pairs([1,2,3]))
print(sum_distinct_pairs([1,4,5]))
# program to compute the summation of the absolute difference of all distinct pairs in an given array 
# (non-decreasing order).
def sum_distinct_pairs(arr):
    result = 0
    i = 0
    while i<len(arr):
        result+=i*arr[i]-(len(arr)-i-1)*arr[i]
        i+=1
    return result
print(sum_distinct_pairs([1,2,3]))
print(sum_distinct_pairs([1,4,5]))
# program to compute the summation of the absolute difference of all distinct pairs in an given array # (non-decreasing order).