def city(to_buy):
    """Calculates the city cost."""
    if 1 < to_buy < 10000:
        return 50000 * (to_buy - 2) ** 3 + 150000 * (to_buy - 1) + 75000
    raise ValueError(
        'You specified an invalid city amount, the min is 1 and max is 10000.')
