Java easy solution , O(n)
\nclass Solution {\n     public int mod = (int)1e9+7;\n    public int kConcatenationMaxSum(int[] arr, int k) {\n        if(arr.length==1) return arr[0]<0 ? 0: a
```\nclass Solution {\n     public int mod = (int)1e9+7;\n    public int kConcatenationMaxSum(int[] arr, int k) {\n        if(arr.length==1) return arr[0]<0 ? 0: arr[0];\n        if(k==1) return (int)(kadane1(arr));\n        \n        long sum = 0;\n        for(int v: arr)sum =sum+v;\n        \n        long ans;\n        if(sum<0){\n           long res = kadane2(arr);\n           ans = res<0 ? 0 : res;\n        }else{\n            ans = (kadane2(arr)+ sum*(k-2)%mod)%mod;\n        }\n        return (int)(ans%mod);\n    }\n    public long kadane1(int[] arr){\n      long max = -(long)1e9;\n      long res = -(long)1e9;\n        \n      for(int i=0; i<arr.length; i++){\n        max = Math.max(max+arr[i], arr[i]);\n        res = Math.max(res, max);\n      }\n      \n      return res;\n  }\n    \n    public long kadane2(int[] arr){\n      long max = -(long)1e9;\n      long res = -(long)1e9;\n        \n      for(int i=0; i<2*arr.length; i++){\n        max = Math.max(max+arr[i%arr.length], arr[i%arr.length]);\n        res = Math.max(res, max);\n      }\n      \n      return res;  \n  }\n}\n```
[]