JAVA COMPLETE DETAILED SOLUTION WITHOUT COPYING ARRAY
\nclass Solution {\n    long mod = 1000000007;\n    public int kConcatenationMaxSum(int[] arr, int k) {\n        // int kadane = Kadane(arr);\n        if(k == 1
```\nclass Solution {\n    long mod = 1000000007;\n    public int kConcatenationMaxSum(int[] arr, int k) {\n        // int kadane = Kadane(arr);\n        if(k == 1){//#1 when k 1 simply calculate kadanes\n            return (int)(Kadane(arr)%mod);\n        }\n        //#2 else calculate the total sum and then check if sum is -Ve or +Ve\n        long totalSum = 0;\n        for(int i : arr) \n            totalSum += i;\n        \n        //#3 when negative then calculate of arr 2 times only the answer is in there only\n        if(totalSum < 0){\n            return (int)(Math.max(KadaneTwo(arr)%mod,0));//when -ve sum put a extra check here of max from 0\n        }else{\n        //#4 when sum is positve then the ans is kadane of 2 + sum * (k-2);//these two are used sUm*(k-2) ensures that all other are also included\n            return (int)((KadaneTwo(arr) + ((k-2) * totalSum)  + mod) % mod );\n        } \n    }\n    \n    private long Kadane(int[] arr){\n        long max = arr[0] , cur = 0;\n        for(int n : arr){\n            cur += n;\n            max = Math.max(max, cur);\n            if(cur < 0) cur = 0;\n        }\n        return max;\n    }\n    \n    private long KadaneTwo(int[] arr){\n      // WITHOUT CREATING THE COPY OF THE ORIGINAL ARRAY SO SPACE COMPLEXITY BECOMES O(1) AND USING Circular Indexing\n        long max = arr[0] , cur = 0;\n        for(int i = 0;i < arr.length*2;i++){\n            cur += arr[i%arr.length];\n            max = Math.max(max, cur);\n            if(cur < 0) cur = 0;\n        }\n        return max;\n\t\t\n\t\t /* CREATING A COPY APPROACH NOT RECOMMENDED\n        int ar[] = new int[arr.length*2];\n        for(int i = 0;i<arr.length*2;i++){doubling the length can be reduced to below FOR\n            ar[i] = arr[i%arr.length];\n        } */\n\t\t/*\n        int n = arr.length;\n        for(int i = 0;i<arr.length;i++){\n            ar[i] = ar[i+n] = arr[i];\n        }\n        return Kadane(ar);\n        */\n    }\n}\n```
[]