def main(): n = int(input()) m = list(map(int, input().split())) list1 = [0] * n list1[0] = m[0] if n > 2: list1[1] = max(list1[0], m[1]) for index in range(n - 2): list1[index + 2] = max(list1[index] + m[index + 2], list1[index + 1]) print(max(list1)) elif n == 1: list1[0] = max(list1[0], m[0]) print(list1[0]) elif n == 2: list1[0] = max(list1[0], m[0]) print(list1[0]) if __name__ == '__main__': main()