Simple Java Solution | Beats 100%
\n\n# Code\njava []\nclass Solution {\n    long gcd(long a, long b)  \n    {  \n        return b == 0 ? a: gcd(b, a % b);     \n    }\n\n    long lcm(int[] arr,
\n\n# Code\n```java []\nclass Solution {\n    long gcd(long a, long b)  \n    {  \n        return b == 0 ? a: gcd(b, a % b);     \n    }\n\n    long lcm(int[] arr, int idx, int r)\n    {\n        if (idx == arr.length - 1){\n            if(idx == r) return 1;\n            return arr[idx];\n        }\n        if(r == idx){\n            idx += 1;\n        }\n        if (idx == arr.length - 1){\n            return arr[idx];\n        }\n        long a = arr[idx];\n        long b = lcm(arr, idx+1, r);\n        return (a*b/gcd(a,b)); \n    }\n    public long maxScore(int[] nums) {\n        long lcm = 0, gcd = 0, prod = 0;\n        int  n = nums.length;\n        gcd = nums[0];\n        for (int element: nums){\n            gcd = gcd(gcd, element);\n\n            if(gcd == 1)\n            {\n               break;\n            }\n        }\n        lcm = lcm(nums,0,-1);\n        prod = gcd*lcm;\n        for(int i=0;i<n;i++){\n            gcd = i == n-1 ? nums[0] : nums[i+1];\n            for(int j=0;j<n;j++){\n                if(j == i)continue;\n                gcd = gcd(gcd,nums[j]);\n            }\n            lcm = lcm(nums,0,i);\n            prod = Math.max(gcd*lcm,prod);\n        }        \n        return prod;\n    }\n}\n```
['Java']