[INST] Design an algorithm to find the maximum profit of a stock buy and sell when given it's historical prices./n [/INST]  ###Response: Here's a simple algorithm to find the maximum profit of a stock buy and sell:

1. Initialize variables: 
   - min_price = historical_prices[0] (set the minimum value to the first price)
   - max_profit = 0 (set the maximum profit to zero)

2. Loop through each price in the historical prices:
   - If the current price is less than the minimum price, update the minimum price with the current price.
   - Otherwise, calculate the current profit by subtracting the minimum price from the current price.
   - If the current profit is greater than the maximum profit, update the maximum profit with the current profit.

3. Return the maximum profit.

Here's the code implementation in Python:

```
def max_stock_profit(historical_prices):
    min_price = historical_prices[0]
    max_profit = 0
    
    for price in historical_prices:
        if price < min_price:
            min_price = price
        else:
            profit = price - min_price
            if profit > max_profit:
                max_profit = profit
                
    return max_profit
```

Simply call the function `max_stock_profit` with a list of historical prices as argument to obtain the maximum profit that can be earned by buying and selling the stock.