python solution
Code\n\nclass Solution:\n    def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n        \n        mod = 1000000007\n        ans = 0\n        ln = l
# Code\n```\nclass Solution:\n    def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n        \n        mod = 1000000007\n        ans = 0\n        ln = len(nums)\n        \n        for i in range(ln):\n            if s[i] == \'L\':\n                nums[i] -= d\n            else:\n                nums[i] += d\n        \n        nums.sort()\n\n        cnt = 1\n        for i in range(1, len(nums)):\n            multiplier = (ln - i) * cnt\n            diff = abs(nums[i] - nums[i-1])\n            ans += diff * multiplier\n            cnt += 1\n        \n        return int(ans % mod)\n```
['Python3']