n, *a = map(int, open(0).read().split()) b, c = 0, -float('inf') for i in a: b, c = max(b, c + i), max(c, b - i) print(max(b, c))