def median(x):
    """
	Calculates the median value of an array
	"""
    x.sort()
    n = len(x)
    if n < 1:
        print('List too short.')
        return
    if n % 2 == 1:
        return x[n // 2]
    else:
        return sum(x[n // 2 - 1:n // 2 + 1]) / 2.0
