integer(16) N
integer(16),allocatable,dimension(:)::A
integer(16),allocatable,dimension(:,:)::DP
read*,N
allocate(A(N))
read*,A
allocate(DP(N,N))
DP=huge(N)

print"(i0)",DFS(1,1)

contains
recursive function DFS(turn,l)result(res)
  integer,intent(in)::turn,l
  integer(16) res
  integer r
  if(DP(turn,l)/=huge(N))then
    res=DP(turn,l)
    return
  endif
  r=N-turn+l
  select case(mod(turn,2))
    case(1)!Taro's turn
      if(turn==N)then
        res=A(l)
        return
      endif
      res=max(DFS(turn+1,l+1)+A(l),DFS(turn+1,l)+A(r))
    case(0)!Jiro's turn
      if(turn==N)then
        res=-A(l)
        return
      endif
      res=min(DFS(turn+1,l+1)-A(l),DFS(turn+1,l)-A(r))
  end select
  DP(turn,l)=res
  return  
end function
end