620. Buy and Sell Stock - III
You are given an array of stock prices. Your task is to determine the maximum profit you can make by buying and selling the stock at most two times. The transactions must not overlap, meaning you can only buy the second stock after selling the first one.
The first line of input contains the number of elements N in the array. The second line contains N space-separated elements denoting the price of the stock on the i'th day.
Print the maximum profit on a single line.
8 3 3 5 0 0 3 1 4