Thanks_up寒假带了线代书回家老惨了。
他在复习线代,没错他在复习线代,然后他是这样子的
紧接着他是这样子的
然后他就玩起了游戏(ˉ▽ ̄~) 切~~
他给了自己n个0,然后他要对区间内做操作,但是他要提高一下难度,所以他只能做两个操作
1:对区间内的数+1
2:对区间内地数-1
问他最少操作几次能够达到他想要的数。
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the length of the array ai. Initially ai = 0 for every position i, so this array is not given in the input.
The second line of the input contains n integers b1, b2, ..., bn ( - 109 ≤ bi ≤ 109).
第一行是一个数n (1 ≤ n ≤ 200 000) ,代表有多个数。
第二行输入n个数,代表Thanks_up想要的数
Print the minimum number of steps that Wilbur needs to make in order to achieve ai = bi for all i.
输出一个数,代表要最少经过几个操作能够把数变成已知的
5
1 2 3 4 5
5
4
1 2 2 1
3
NoteIn the first sample, Wilbur may successively choose indices 1, 2, 3, 4, and 5, and add 1 to corresponding suffixes.
In the second sample, Wilbur first chooses indices 1 and 2 and adds 1 to corresponding suffixes, then he chooses index 4 and subtract 1.