class Solution:
    def rob(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        n=len(nums)
        if n==0:
            return 0
        if n==1:
            return nums[0]
        index=[0 for i in range(n+2)]
        index2 = [0 for i in range(n + 2)]
        #不考虑最后一个
        for i in range(2,n+1):
            index[i]=max(index[i-1],index[i-2]+nums[i-2])
        #不考虑第一个
        for i in range(3,n+2):
            index2[i]=max(index2[i-1],index2[i-2]+nums[i-2])
        return max(index[n],index2[n+1])
input=[2,3,2]
s=Solution()
print(s.rob(input))
#最后一个和最前面一个是相邻的