import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val A = new Array[Int](N+1)
  for (i <- 1 to N)
    A(i) = in.next().toInt

  //
  val odd = new Array[Long](N+1)
  val even = new Array[Long](N+1)
  odd(1) = A(1)
  even(2) = A(2)
  for (i <- 3 to N by 2) {
    odd(i) = odd(i-2) + A(i)
  }
  for (i <- 4 to N by 2) {
    even(i) = even(i-2) + A(i)
  }


  var ans = 0L
  if (N % 2 == 0) {
    ans = odd(N-1) max even(N)

    for (i <- 1 to N-1-1) {
      var res = 0L
      if (i % 2 == 1) {
        if (i >= 3)
          res += odd(i-2)
        res += odd(N-1) - odd(i)
      }
      else {
        res += odd(i-1) max even(i-2)
        res += Math.max(odd(N-1) - odd(i+1), even(N) - even(i))
      }

      ans = Math.max(ans, res)
    }
  }
  else { // N is odd
    for (i <- 1 to N-1) {
      var res = 0L

      if (i % 2 == 1) {
        res += even(i-1)
        if (i >= 3)
          res = Math.max(res, odd(i-2))
        res += odd(N) - odd(i)
      }
      else {
        res += odd(i-1)
        res += Math.max(odd(N) - odd(i+1), even(N-1) - even(i))
      }
      //println(res, i)

      ans = Math.max(ans, res)
      ans = Math.max(ans, even(N-1))
    }
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
