cpp
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n#pragma GCC optimize("O3")\nclass Solution {\npublic:\n    const int mod=1e9+7;\n    int sumDistance(vector<int>& nums, string s, int d) \n    {\n        int n=nums.size();\n        vector<long long> A(n, 0L);\n        #pragma unroll\n        for(int i=0; i<n; i++){\n            A[i]=(s[i]==\'R\')?(long long)nums[i]+d:(long long)nums[i]-d;\n        }\n        sort(A.begin(), A.end());\n        long long distance=0;\n        #pragma unroll\n        for(int i=0; i<n; i++)\n           distance=(distance+(-n+1+(2L*i))*A[i])%mod;\n        return distance<0?distance+mod:distance;\n    }\n};\n```
['C++']