CodeLab Academy 📞 9936 6696
← List Python · Level 10: Algorithms Code · 100 points ← #942 #944 →

#943. Stocks: one trade

You get the price of a stock for each day. Buy once and sell once later. Find the largest profit (0 if you cannot make a profit). ### Input The first line has n, the second line has n integers separated by spaces. ### Output A number.

Examples

Input
9
24 54 76 98 82 15 85 78 31
Output
74
Input
14
2 38 22 72 75 78 94 49 52 34 61 4 44 13
Output
92

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!