input: from typing import List
  
  def max_revenue(prices: List[int]) -> int:
      """
      Calculate the maximum revenue that can be obtained by buying and selling at the right times.
      >>> max_revenue([10, 7, 5, 8, 11, 9])
      6
      """
output:     max_profit = 0
      min_price = float('inf')
      
      for price in prices:
          if price < min_price:
              min_price = price
          elif price - min_price > max_profit:
              max_profit = price - min_price
      
      return max_profit