def main():

    from collections import defaultdict



    inf = 10 ** 15



    N = int(eval(input()))

    *a, = list(map(int, input().split()))



    it = iter(a)



    dp = [defaultdict(lambda: -inf) for _ in range(N + 1)]

    dp[0][0] = 0

    dp[1][0] = 0

    dp[1][1] = next(it)

    for i, x in enumerate(it, 2):

        mi = (i - 1) // 2

        ma = (i + 1) // 2

        for taken_count in range(mi, ma + 1):

            dp[i][taken_count] = max(

                dp[i - 1][taken_count],

                dp[i - 2][taken_count - 1] + x

            )



    ans = dp[N][N // 2]



    print(ans)





if __name__ == '__main__':

    main()

def main():

    from functools import lru_cache

    import sys



    sys.setrecursionlimit(10 ** 7)



    inf = 2 * 10 ** 14 + 1



    N = int(eval(input()))

    *a, = list(map(int, input().split()))



    @lru_cache(maxsize=None)

    def recursion(cur, need):

        """

        cur: pickableなindex

        """

        if cur >= N:

            if need == 0:

                return 0

            else:

                return -inf



        rest = N - cur

        if (rest + 1) // 2 < need:

            return -inf



        return max(

            a[cur] + recursion(cur + 2, need - 1),

            recursion(cur + 1, need)

        )



    ans = recursion(0, N // 2)



    print(ans)





if __name__ == '__main__':

    main()

def main():
    from collections import defaultdict

    inf = 10**15
    N = int(eval(input()))
    (*a,) = list(map(int, input().split()))
    it = iter(a)
    dp = [defaultdict(lambda: -inf) for _ in range(N + 1)]
    dp[0][0] = 0
    dp[1][0] = 0
    dp[1][1] = next(it)
    for i, x in enumerate(it, 2):
        mi = (i - 1) // 2
        ma = (i + 1) // 2
        for taken_count in range(mi, ma + 1):
            dp[i][taken_count] = max(
                dp[i - 1][taken_count], dp[i - 2][taken_count - 1] + x
            )
    ans = dp[N][N // 2]
    print(ans)


if __name__ == "__main__":
    main()

def main():
    from functools import lru_cache
    import sys

    sys.setrecursionlimit(10**7)
    inf = 2 * 10**14 + 1
    N = int(eval(input()))
    (*a,) = list(map(int, input().split()))

    @lru_cache(maxsize=None)
    def recursion(cur, need):
        """
        cur: pickableなindex
        """
        if cur >= N:
            if need == 0:
                return 0
            else:
                return -inf
        rest = N - cur
        if (rest + 1) // 2 < need:
            return -inf
        return max(a[cur] + recursion(cur + 2, need - 1), recursion(cur + 1, need))

    ans = recursion(0, N // 2)
    print(ans)


if __name__ == "__main__":
    main()

-    from collections import defaultdict +    from functools import lru_cache +    import sys -    inf = 10**15 +    sys.setrecursionlimit(10**7) +    inf = 2 * 10**14 + 1 -    it = iter(a) -    dp = [defaultdict(lambda: -inf) for _ in range(N + 1)] -    dp[0][0] = 0 -    dp[1][0] = 0 -    dp[1][1] = next(it) -    for i, x in enumerate(it, 2): -        mi = (i - 1) // 2 -        ma = (i + 1) // 2 -        for taken_count in range(mi, ma + 1): -            dp[i][taken_count] = max( -                dp[i - 1][taken_count], dp[i - 2][taken_count - 1] + x -            ) -    ans = dp[N][N // 2] + +    @lru_cache(maxsize=None) +    def recursion(cur, need): +        """ +        cur: pickableなindex +        """ +        if cur >= N: +            if need == 0: +                return 0 +            else: +                return -inf +        rest = N - cur +        if (rest + 1) // 2 < need: +            return -inf +        return max(a[cur] + recursion(cur + 2, need - 1), recursion(cur + 1, need)) + +    ans = recursion(0, N // 2)