Easy DP Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public long maximumTotalCost(int[] nums) {\n        long res1=nums[0],res2=nums[0];\n        for(int i=1;i<nums.length;i++){\n            long temp1=res1+nums[i];\n            temp1=Math.max(temp1,res2+nums[i]);\n            long temp2=res1-nums[i];\n            res1=temp1;\n            res2=temp2;\n        }\n        return Math.max(res1,res2);\n    }\n}\n```
['Java']