def median(a):
    """
    Return the median of the elements of array a.
    """
    b = list(a)  # Make a copy of a.
    b.sort()
    length = len(b)
    if length % 2 == 1:
        return b[length//2]
    else:
        return float(b[length//2 - 1] + b[length//2]) / 2.0