K-Concatenation Maximum Sum
public int kConcatenationMaxSum(int[] arr, int k) {\n        long sum=0;\n        for(int i=0;i<arr.length;i++){\n            sum +=arr[i];\n        }\n        
public int kConcatenationMaxSum(int[] arr, int k) {\n        long sum=0;\n        for(int i=0;i<arr.length;i++){\n            sum +=arr[i];\n        }\n        int ans=0;\n        if(k==1){\n             ans=(int)(kadane(arr)%1000000007);\n            return Math.max(ans,0);\n        }\n           \n        int a[]=new int[2*arr.length];\n        int n=arr.length;\n        for(int i=0;i<arr.length;i++){\n            a[i]=a[i+n]=arr[i];\n        }\n        if(sum<0){\n            \n            ans=(int)(kadane(a)%1000000007);\n            return Math.max(ans,0);\n        }else{\n            ans=(int)((kadane(a)+(k-2)*sum)%1000000007);\n            return Math.max(ans,0);\n        }\n    }\n    public long kadane(int a[]){\n        long curBest=a[0], overallBest=a[0];\n        for(int i=1;i<a.length;i++){\n            if(curBest>=0){\n                curBest =curBest+a[i];\n            }\n            else{\n                curBest =a[i];\n            }\n            overallBest=Math.max(overallBest,curBest);\n        }\n        return overallBest;\n    }
['Java']