def mss()
  n = 1
  loop do
    a = []
    n = gets.to_i
    if n == 0
      break
    end
    a[0] = n
    for i in 1..a[0]
      a[i] = gets.to_i
    end
    b = []
    b[0] = a[1]
    for i in 1..a[0]-1
      c = [b[i-1]+a[i+1], a[i+1]]
      b[i] = c.max
    end
    s = b.max
    puts s
  end
end

mss()

