Simple Kadane's
Code\n\nconst long long MOD = 1e9 + 7;\n\nclass Solution {\npublic:\n    int kConcatenationMaxSum(vector<int>& arr, int k) {\n        \n        int n = arr.size
# Code\n```\nconst long long MOD = 1e9 + 7;\n\nclass Solution {\npublic:\n    int kConcatenationMaxSum(vector<int>& arr, int k) {\n        \n        int n = arr.size();\n        long long sum = 0;\n\n\n        long long curr = 0;\n        long long maxSub = 0;\n\n        for(int i = 0; i < n; i++) {\n            curr += arr[i];\n            maxSub = max(maxSub, curr);\n            if(curr < 0) {\n                curr = 0;\n            }\n            sum += arr[i];\n        }\n\n        curr = 0;\n\n        long long maxSubTwo = 0;\n        for(int i = 0; i < 2*n; i++) {\n            curr += arr[i % n];\n            maxSubTwo = max(maxSubTwo, curr);\n            if(curr < 0) {\n                curr = 0;\n            }\n        }\n\n        if(k == 1) {\n            return maxSub;\n        } else if(k == 2) {\n            return maxSubTwo % MOD;\n        } else {\n            if(sum >= 0) {\n                long long val1 = ( (sum % MOD ) * ((k - 2) * 1LL % MOD) ) % MOD;\n                long long val2 = maxSubTwo % MOD;\n                long long finalSum = (val1 + val2) % MOD;\n                return finalSum;\n            } else {\n                return maxSubTwo;\n            }\n        }\n\n        \n    }\n};\n```
['C++']