C++ solution of time complexity O(n^2)  space complexity O(1)
Intuition\nTo solve the problem of finding the maximum score, which is defined as the product of the least common multiple (LCM) and the greatest common divisor
# Intuition\nTo solve the problem of finding the maximum score, which is defined as the product of the least common multiple (LCM) and the greatest common divisor (GCD) of a given array, we can think of two main operations:\n\n1. **GCD and LCM Calculations:** We need to compute the GCD and LCM of the entire array.\n2. **Deletion of Elements:** For each element in the array, if we consider removing it, we will recalculate the LCM and GCD for the remaining elements to see if we can get a higher score.\nOur goal is to maximize the score after possibly deleting one element from the array.\n\n# Approach\n1. GCD Function: Implement a recursive function to calculate the GCD using the Euclidean algorithm. This function will continue reducing the numbers until one becomes zero.\n\n2. LCM Function: Define an LCM function that utilizes the relationship between GCD and LCM:\n\n**LCM(\uD835\uDC4E,\uD835\uDC4F) = (\uD835\uDC4E\xD7\uD835\uDC4F)/GCD(\uD835\uDC4E,\uD835\uDC4F)**\n\n \n3. GCD of Array: Write a function to calculate the GCD of all elements in the array. Start with the first element and iteratively compute the GCD with each subsequent element.\n\n4. LCM of Array: Similarly, write a function to compute the LCM of all elements in the array using a loop.\n\n5. Max Score Calculation: Initialize the maximum score by calculating the score using the LCM and GCD of the entire array. Then iterate through each element:\n\n- Remove the element.\n- Compute the LCM and GCD of the remaining elements.\n- Update the maximum score if the new score is higher.\n- Restore the element to its original position.\n\n6. Return the Maximum Score: After considering each element\'s removal, return the maximum score found.\n\n# Complexity\n- Time complexity:\nO(n^2)\n\n- Space complexity:\nO(1)\n\n# Code\n```cpp []\nclass Solution {\nlong long gcd(long long  a, long long b) {\n    return b == 0 ? a : gcd(b, a % b);\n}\n\n// Function to calculate GCD of an entire array\nlong long gcdOfArray(const std::vector<int>& arr) {\n    long long result = arr[0];\n    for (size_t i = 1; i < arr.size(); i++) {\n        result = gcd(result, arr[i]);\n        // If at any point GCD becomes 1, we can stop early\n        if (result == 1) {\n            return 1;\n        }\n    }\n    return result;\n}\nlong long lcm(long long a, long long b) {\n    return (a / std::gcd(a, b)) * b;\n}\n\n// Function to calculate LCM of an entire array\nlong long lcmOfArray(const std::vector<int>& arr) {\n    long long result = arr[0];\n    for (size_t i = 1; i < arr.size(); i++) {\n        result = lcm(result, arr[i]);\n        // If result becomes too large, you might want to add overflow handling here\n    }\n    return result;\n}\npublic:\n    long long maxScore(vector<int>& nums) {\n        int n = nums.size();\n        long long ans = lcmOfArray(nums)*gcdOfArray(nums);\n        for(int i=0;i<n;i++){\n             long long deletedValue = nums[i];\n            nums.erase(nums.begin() + i);\n            ans = max(ans,lcmOfArray(nums)*gcdOfArray(nums));\n            nums.insert(nums.begin() + i, deletedValue);\n        }\n        return ans;\n    }\n};\n```
['C++']