100% beat
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    long long gcd(long long a,long long b){\n        while(a>0 && b>0){\n            if(a>b) a=a%b;\n            else b=b%a;\n        }\n        if(a==0) return b;\n        return a;\n    }\n    long long lcm(long long a,long long b){\n        return (a/(gcd(a,b)))*b;\n    }\n    long long maxScore(vector<int>& nums) {\n        int n = nums.size();\n        if(n==0) return 1;\n        if(n==1) return nums[0]*nums[0];\n        \n        vector<long long> g1(n);\n        vector<long long> g2(n);\n        vector<long long> l1(n);\n        vector<long long> l2(n);\n\n        g1[0] = nums[0];\n        l1[0] = nums[0];\n        for(int i=1;i<n;i++){\n            g1[i] = gcd(g1[i-1],nums[i]);\n            l1[i] = lcm(l1[i-1],nums[i]);\n        }\n\n        g2[n-1] = nums[n-1];\n        l2[n-1] = nums[n-1];\n        for(int i=n-2;i>=0;i--){\n            g2[i] = gcd(g2[i+1],nums[i]);\n            l2[i] = lcm(l2[i+1],nums[i]);\n        }\n        \n        long long maxi = g1[n-1]*l1[n-1];\n\n        for(int i=1;i<n-1;i++){\n            long long temp = gcd(g1[i-1],g2[i+1]) * lcm(l1[i-1],l2[i+1]);\n            maxi = max(maxi,temp);\n        }\n\n        maxi = max(maxi,g1[n-2]*l1[n-2]);\n        maxi = max(maxi,g2[1]*l2[1]);\n        return maxi;\n        \n    }\n};\n```
['Math', 'Prefix Sum', 'C++']