from collections import defaultdict memo = {} def dfs(i, pre_use): if i == len(value_list): return 0 if (i, pre_use) in memo: return memo[(i, pre_use)] ans = 0 ans = max(ans, dfs(i + 1, False)) if not pre_use: ans = max(ans, dfs(i + 1, True) + value_list[i]) memo[(i, pre_use)] = ans return ans if __name__ == '__main__': n = int(input()) value_list = list(map(int, input().split())) print(dfs(0, False))