Given an array of stock values, find the maximum profit achievable with one buy and one sell.
The buy must occur before the sell, and you may complete at most one transaction. Implement max_profit(prices), which accepts a list of integers and returns the maximum profit as an integer. Return 0 when no profitable transaction is possible.
def max_profit(prices):