Best Time to Buy and Sell
Prices of a component for days are given. Buy on one day and sell on a later day to maximise profit. Print the maximum profit (0 if you can't profit).
Input
, then prices.
Output
The maximum profit.
Constraints
Sample 1
Input
6 7 1 5 3 6 4
Output
5
Sample 2
Input
5 7 6 4 3 1
Output
0