```python
def tier_cost(units: int, allowance: int, first_rate: int, later_rate: int) -> int:
    """Calculate the cost of units with a tiered rate structure."""
    if units < 0:
        raise ValueError("Units must be non-negative")

    if units <= allowance:
        return units * first_rate

    return (allowance * first_rate) + ((units - allowance) * later_rate)
```