Company: Capital One_30june
Difficulty: medium
Time Machine Travel Cost Problem Description You have a time machine and a list of years you must visit. You start in the year years[0] . From there you travel to years[1] , then to years[2] , and so on, until you have visited every year in the list. The years are visited strictly in the order they appear in the list - the list is not sorted and must not be reordered. Travelling from year A to year B costs: 0 hours if A = B (you stay in the same year) 1 hour if A < B (going forwards in time) 2 hours if A > B (going backwards in time) Compute the total number of hours needed to complete the whole trip. Input Format (inferred - the source presents years as a function argument and does not fix a console layout.) The first line contains a single integer n , the number of years in the list. The second line contains n space-separated integers years[0] ... years[n-1] . Output Format Print a single integer on its own line: the total number of hours required to visit all the given years i