Beats 100% || Number Theory || Math|| Easy 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```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    \n    long long maxScore(vector<int>& nums) {\n        long long res1 = nums[0];\n        long long res2 = nums[0];\n        int n = nums.size();\n        if(n==0) return 1;\n        if(n==1) return nums[0]*nums[0];\n        vector<pair<long long,long long>> preff(n,{0,0}),suff(n,{0,0});\n        preff[0] = {nums[0],nums[0]};\n        suff[n - 1] = {nums[n - 1], nums[n - 1]};\n        for (int i = 1; i < n; i++) {\n            preff[i].second = gcd(preff[i - 1].second,nums[i]);\n            preff[i].first = lcm(preff[i - 1].first, nums[i]);\n        }\n        for (int i = n - 2; i >= 0; i--) {\n            suff[i].second = gcd(suff[i + 1].second,nums[i]);\n            suff[i].first = lcm(suff[i + 1].first, nums[i]);\n        }\n        long long maxi = preff[n - 1].first * preff[n - 1].second;\n        for(int i = 1;i< n - 1;i++){\n         long long temp = gcd(preff[i - 1].second,suff[i + 1].second) * lcm(preff[i - 1].first,suff[i + 1].first);\n            maxi = max(temp, maxi);\n        }\n        maxi = max(maxi,suff[1].first * suff[1].second);\n        maxi = max(maxi,preff[n - 2].first * preff[n - 2].second); \n        return maxi;\n    }\n};\n```
['Array', 'Math', 'Suffix Array', 'Number Theory', 'Prefix Sum', 'C++']