from itertools import accumulate n = int(input()) a = list(map(int, input().split())) d = [x-y for x, y in zip(a[::2], a[1::2])] print(max(accumulate(d, initial=0))*2 - sum(d))