def buy_sell_once(prices: list[float]) -> float:
assert len(prices) > 1
best_buy, best_so_far = prices[0], 0.0
for i in range(1, len(prices)):
best_so_far = max(best_so_far, prices[i] - best_buy)
best_buy = min(best_buy, prices[i])
return best_so_far