Given an array of event ticket prices, write a function to find the maximum profit you can make by buying and selling a ticket, assuming you can only transact once.
Implement max_profit(prices), where prices[i] is the ticket price on day i. You must buy before selling and may return 0 if no profitable transaction exists. Return the maximum profit as an integer.
def max_profit(prices):