Time - O(n) | min of min | deque
Intuition\n Describe your first thoughts on how to solve this problem. \n\n##### Choose mountain peak index i, iterate between index 1 to len(n)-1\n    we start
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n##### Choose mountain peak index i, iterate between index `1` to `len(n)-1`\n    we start with index `1` because for a mountain we need atleast one element to left\n    we end at index `len(n)-1` because for a mountain we need atleast one element to right\n\nFirst for loop:\n\n    for mountain peak i find the minimun to its left\n\nSecond for loop:\n    \n    for mountain peak i find the minimun to its right\n\nIn third for loop, confirm a mountain is formed using if condition `if ml < nums[i] and nums[i] > mr:`\n\n    if a mountain is formed , comapare it whith `ans` , update `ans` if it is small than already known `ans`\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def minimumSum(self, nums: List[int]) -> int:\n        min_left = deque()\n        min_right = deque()\n\n        ml = nums[0]\n        mr = nums[-1]\n\n        min_left.append(ml)\n        min_right.appendleft(mr)\n\n        ans = float(\'inf\')\n\n        for i in range(1, len(nums) - 2):\n            if nums[i] < ml:\n                ml = nums[i]\n            min_left.append(ml)\n\n        for i in range(len(nums) - 2, 1, -1):\n            if nums[i] < mr:\n                mr = nums[i]\n            min_right.appendleft(mr)\n\n        for i in range(1, len(nums) - 1):\n            ml = min_left.popleft()\n            mr = min_right.popleft()\n            if ml < nums[i] and nums[i] > mr:\n                ans = min(ans , nums[i] + ml + mr)\n\n        if ans == float(\'inf\'):\n            return -1\n        else:\n            return ans\n```
['Python3']