IntermediateRating 1100
Buy Once, Sell Once
Given prices on n days, buy on one day and sell on a later day. Print the largest profit, or 0 if no profit is possible.
Input
n, then n prices.
Output
One integer.
Sample 1
Input
6 7 1 5 3 6 4
Output
5
Sample 2
Input
5 7 6 4 3 1
Output
0
Output appears here