Beat 100% , TC = O(n log(min(a, b))) , SC = O(n).
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```cpp []\nclass Solution {\npublic:\n    int hcf(vector<int>&nums)\n  {\n    int h = nums[0];\n    for(int i =0;i<nums.size();i++)h = gcd(h,nums[i]);\n    return h;\n  }\n  long long lcm(vector<int>nums)\n  {\n    long long l = nums[0];\n    for(int i =0;i<nums.size();i++)l= (l*nums[i])/gcd(l,nums[i]);\n    return l;\n  }\n    long long maxScore(vector<int>& nums) {\n     long long res = hcf(nums)*lcm(nums); \n     if(nums.size()==1)return (nums[0]*nums[0]);\n     for(auto x : nums)\n     {\n        vector<int>temp = nums;\n        auto it = find(temp.begin(),temp.end(),x);\n        if(it!=temp.end())temp.erase(it);\n        res = max(res,hcf(temp)*lcm(temp));\n         }\n     return res;\n    }\n};\n```
['C++']