Chat in Telegram

Find maximum difference between two elements

EASY

Given a string of numbers separated by a single space.

Find the maximum difference between two elements in the string such that smaller element appears after the larger element.

For example, answer for string "1 6 4 3" is: "3" (6-3)

Example #1

Input

1 6 4 3

Output

3

Solution