Easiest 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```java []\nclass Solution {\n    private long gcd(long a, long b) {\n        return b == 0 ? a : gcd(b, a % b);\n    }\n\n    private long gcdOfArray(int[] arr) {\n        long result = arr[0];\n        for (int num : arr) {\n            result = gcd(result, (long)num);\n        }\n        return result;\n    }\n\n    private long lcm(long a, long b) {\n        return (a * b) / gcd(a, b);\n    }\n\n    private long lcmOfArray(int[] arr) {\n        long result = arr[0];\n        for (int num : arr) {\n            result = lcm(result, (long)num);\n        }\n        return result;\n    }\n\n  \n    public long maxScore(int[] nums) {\n        int n = nums.length;\n        if (n == 1) {\n            return (long) nums[0] * nums[0];\n        }\n\n        long totalGCD = gcdOfArray(nums);\n        long totalLCM = lcmOfArray(nums);\n        long maxScore =  totalGCD * totalLCM;\n\n        for (int i = 0; i < n; i++) {\n            int[] tempArray = new int[n - 1];\n            int index = 0;\n            for (int j = 0; j < n; j++) {\n                if (j != i) {\n                    tempArray[index++] = nums[j];\n                }\n            }\n\n            long currentGCD = gcdOfArray(tempArray);\n            long currentLCM = lcmOfArray(tempArray);\n            long currentScore =currentGCD * currentLCM;\n\n            maxScore = Math.max(maxScore, currentScore);\n        }\n\n        return maxScore;\n    }\n}\n\n```
['Math', 'Java']