C# Solution that passes all the test cases
Complexity\n- Time complexity: O(nlogn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(n)\n Add your space complexity here, e.g. O(n) \n\n#
# Complexity\n- Time complexity: $$O(nlogn)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\npublic class Solution {\n    public int SumDistance(int[] nums, string s, int d) {\n        var longNums = new long[nums.Length];\n        for (int i = 0; i < nums.Length; i++)\n        {\n            nums[i] %= 1000000007;\n\n            if (s[i] == \'L\') longNums[i] = nums[i] - d;\n            else longNums[i] = nums[i] + d;\n        }\n\n        Array.Sort(longNums);\n\n        long result = 0;\n        long prefix = 0;\n        for (int i = 0; i < longNums.Length; i++)\n        {\n            result += i * longNums[i] - prefix;\n            result %= 1000000007;\n            \n            prefix += longNums[i];\n            prefix %= 1000000007;\n        }\n\n        return (int)result;\n    }\n}\n```
['C#']