Simple Solution in Java || Elegant and Concise || O(n) Space and O(n) Time
\nclass Solution {\n    public int sumOfBeauties(int[] nums) {\n        int[] minEle = new int[nums.length];\n        \n        int min = nums[nums.length-1];\n
```\nclass Solution {\n    public int sumOfBeauties(int[] nums) {\n        int[] minEle = new int[nums.length];\n        \n        int min = nums[nums.length-1];\n        for(int i=nums.length-2; i>=1; i--){\n            minEle[i] = min;\n            min = Math.min(min, nums[i]);\n        }\n        \n        int max = nums[0];\n        int ans = 0;\n        for(int i=1; i<nums.length-1; i++){\n            if(max < nums[i] && nums[i] < minEle[i]){\n               ans += 2;   \n            }else if(nums[i-1] < nums[i] && nums[i] < nums[i+1]){\n                ans += 1;\n            }\n            \n            max = Math.max(max, nums[i]);\n        }\n        \n        return ans;\n    }\n}\n```
[]