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