Java Simple and Short O(n) Solution
\n\n# Code\n\nclass Solution {\n    public int kConcatenationMaxSum(int[] arr, int k) {\n        long sum=0l,min=0l,max=0l;\n        int mod=(int)1e9+7;\n      
\n\n# Code\n```\nclass Solution {\n    public int kConcatenationMaxSum(int[] arr, int k) {\n        long sum=0l,min=0l,max=0l;\n        int mod=(int)1e9+7;\n        for(int i=0;i<k && i<2;i++){\n            for(int ele:arr){\n                sum+=ele;\n                max=Math.max(max,sum-min);\n                min=Math.min(min,sum);\n            }\n        }\n        max+=((k<2)?0l:((k-2)*(sum>0?(sum>>1):0)));    \n        return (int)(max%mod);\n    }\n}\n```
['Java']