N = int(input()) C = list(map(int, input().split())) ans = abs(C[0]) + abs(C[N-1]) for i in range(N-1): ans += C[i+1] - C[i] print(ans)