JAVA 1ms with GCD
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    public long maxScore(int[] n) {\n        if(n.length==1)return n[0]*n[0];\n        long[] rg = new long[n.length];\n        long[] rl = new long[n.length];\n\n        rg[n.length-1]=rl[n.length-1]=n[n.length-1];\n\n        for(int i=n.length-2; i>=0; i--){\n            rg[i]=gcd(rg[i+1],n[i]);\n            rl[i]=rl[i+1]*n[i]/gcd(rl[i+1],n[i]);\n        }\n        long a = Math.max(rg[0]*rl[0], rg[1]*rl[1]);\n\n        long lg=n[0], ll=n[0], t;\n        for(int i=1; i<n.length-1; i++){\n            t = gcd(lg,rg[i+1]) * (ll*rl[i+1])/gcd(ll,rl[i+1]);\n            if(a<t)a=t;\n            lg=gcd(lg, n[i]);\n            ll=ll*n[i]/gcd(ll,n[i]);\n        }\n        return Math.max(a, lg*ll);\n    }\n    private long gcd(long a, long b){\n        if(b%a==0)return a;\n        return gcd(b%a, a);\n    }\n}\n```
['Java']