from functools import reduce


def solve(ar):
    """
    Given an array of 5 integers, return the minimal and maximal sum of 4 out of
    5 of the integers.
    """
    # Just sort the list of integers in place and take the sum of the first 4
    # then the last 4.
    ar.sort()
    minSum = reduce((lambda x, y: x + y), ar[0:4])
    maxSum = reduce((lambda x, y: x + y), ar[1:5])
    return (minSum, maxSum)