input: from typing import List
  
  def max_revenue(prices: List[int]) -> int:
      """ Calculate the maximum revenue that can be obtained from buying and selling stocks given a list of prices.
      
      >>> max_revenue([10, 7, 5, 8, 11, 9])
      6
      >>> max_revenue([3, 3, 5, 0, 0, 3, 1, 4])
      4
      """
output:     if not prices:
          return 0
      
      min_price = prices[0]
      max_profit = 0
      
      for price in prices:
          min_price = min(min_price, price)
          max_profit = max(max_profit, price - min_price)
      
      return max_profit