10370 - Insider Stock Trading   

Description

The cost of a stock on each day is given in an array, find the max profit that you can make by buy and sell only once in those days.  For example, if the given array is <180, 260, 310, 40, 695>, the maximum profit can earned by buying on day 3, selling on day 4; the profit is 655.

Input

Each line of the input contains a series of positive integers seperating by one white space, representing the prices of a stock. Input file is terminated by end of file.

Output

For each line of input you will have to produce one line of output which is the maximum of profit you can gain if you can buy and sell stock only once.

Sample Input  Download

Sample Output  Download

Tags




Discuss