🐍Python solution✅ Beats 82.83%✨
\n\n# Code\n\nclass Solution:\n    def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n        MOD = 10**9 + 7\n\n        for i in range(len(nums)):
\n\n# Code\n```\nclass Solution:\n    def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n        MOD = 10**9 + 7\n\n        for i in range(len(nums)):\n            if s[i] == "R":\n                nums[i] += d\n            else:\n                nums[i] -= d\n\n        nums.sort()\n\n        result = 0\n        running_sum = 0\n\n        for i, pos in enumerate(nums):\n            result += i * pos - running_sum\n            result %= MOD\n            running_sum += pos\n\n        return result\n\n\n\n```
['Python3']