Be Careful The Data Type Size
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```csharp []
public class Solution {
    public int SumDistance(int[] nums, string s, int d) {
        int len = s.Length, mod = 1000000007;
        long[] sample = new long[len];
        for(int i = 0; i < len; i++)
        {
            sample[i] = (long)nums[i]+ (s[i] == 'R' ? d : -d);
        }

        Array.Sort(sample);
        long sum = 0;

        for(int i = 1; i < len; i++)
        {
            sum += (sample[i] - sample[0]); // all diffs which contains idx 0
        }

        long res = sum;
        for(int i = 1; i < len; i++)
        {
            sum -=(sample[i] - sample[i-1])*(len-i); // slide window: - the sum which start with i-1
            res += sum;
            res %= mod;
        }

        return (int)res;
    }
}
```
['C#']