python different possibilities
First determine if both positive and negative numbers exists. \nIf only positive exists, results is simpley sum(arr) * k.\nIf only negative number exists, resul
First determine if both positive and negative numbers exists. \nIf only positive exists, results is simpley sum(arr) * k.\nIf only negative number exists, result is zero\nIf both exists,\nThe result is either\n\t1. max(bestSum) in the arr \n\t2. sumArr * k\n\t3. sumArr * (k - 1 ) - max(bestSum) of arr when tails are not considered\n\n\n\n```\nclass Solution:\n    def kConcatenationMaxSum(self, arr: List[int], k: int) -> int:\n        \n        n = len(arr)\n        sumArr = sum(arr)\n        \n        neg = False\n        pos = False\n        both = False\n        \n        for i in range(n):\n            if neg == False and arr[i] < 0:\n                neg = True\n            if pos == False and arr[i] >= 0:\n                pos = True\n            if neg and pos:\n                both = True\n                break\n                \n        if not both:\n            return 0 if neg else sumArr * k  %(10**9 + 7)\n        \n        maxSum = 0\n        curSum = 0\n        for i in range(min(k,2)*n):\n            if curSum + arr[i%n] < 0:\n                curSum = 0\n            else:\n                curSum += arr[i%n]\n            maxSum = max(maxSum, curSum)\n        bestSum = 0\n        bestMax = 0\n        for i in range(n):\n            if bestSum +arr[i] < 0:\n                bestSum = 0\n            else:\n                bestSum += arr[i]\n            bestMax = max(bestSum, bestMax)\n        return max(max(k*sumArr, maxSum), (k-1)*sumArr +bestMax ) %(10**9 + 7)\n        \n        \n            \n        \n```
[]