Company: Hudson River Trading(HRT)_4th june_on campus _iit guwahti
Difficulty: easy
Time Machine You own a time machine, and you have an itinerary: an array years of n calendar years you must visit in the order given . You begin standing in years[0] , then jump to years[1] , then to years[2] , and so on until you have visited every year on the list. A single jump from year A to year B costs: 0 hours when A == B (you are already there — no jump is made), 1 hour when A < B (travelling forwards in time), 2 hours when A > B (travelling backwards in time). Report the total number of hours the whole itinerary takes. Input Format The first line contains a single integer n — the number of years on the itinerary. The second line contains n space-separated integers years[0] years[1] ... years[n-1] . When n is 1 the second line holds a single value and no jump is ever made. Output Format Print a single integer — the total number of hours needed to visit every year of the itinerary in order. Constraints 1 <= n <= 15000 -1000000000 <= years[i] <= 1000000000 The y