```python
def sum_Pairs(arr, n):
    """
    Calculates the sum of absolute differences in all pairs of the given array.

    Args:
        arr: A list of numbers.
        n: The number of elements in the array.

    Returns:
        The sum of absolute differences between all pairs of elements.
    """
    # Sorting the array allows us to remove the absolute value function.
    # For a sorted array, if i < j, then arr[i] <= arr[j], so |arr[i] - arr[j]| = arr[j] - arr[i].
    arr.sort()

    # The problem is now to calculate the sum of (arr[j] - arr[i]) for all i < j.
    # This can be calculated efficiently in a single pass after sorting.
    # At each element arr[i], we calculate the sum of its differences with all
    # preceding elements: sum(arr[i] - arr[j]) for j < i.
    # This is equal to i * arr[i] - (arr[0] + arr[1] + ... + arr[i-1]).
    # We can maintain a running prefix_sum to compute this efficiently.

    result = 0
    prefix_sum = 0
    for i in range(n):
        # Contribution of pairs with the current element and all previous elements
        result += i * arr[i] - prefix_sum
        
        # Update the prefix sum to include the current element for the next iteration
        prefix_sum += arr[i]

    return result
```