stop the modulo
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```\nimport java.util.*;\n\npublic class Solution {\n    \n//    Read and learn this explanation, ignore the retarded test cases \n//    That play around long/int and modulo and waste your time...\n\n//    public int sumDistance(int[] nums, String s, int d) {\n//        final int mod = 1_000_000_007;\n//        for (int i = 0; i < nums.length; i++) {\n//            nums[i] += d * (s.charAt(i) == \'R\' ? 1 : -1);\n//        }\n//\n//        Arrays.sort(nums);\n//        long sum = 0;\n//        int n = nums.length;\n//\n//        // SUM OF ALL DIST PAIRS: sorted array\n//        // every number A[i] will be present in the final equation (N - 1) times!!\n//        // {1,2,3} => {1,2} {1,3} {2,3} =\n//        // pair each number with all previous!!!\n//        // each time subtract the smaller of the pair: BIGGER - SMALLER:\n//        // (2 - 1) + (3 - 1) + (3 - 2)\n//        // each A[i] will be +ADDED for each previous index because it will form\n//        // a pair where A[i] is the bigger!!! It will also form a pair with each\n//        // later index where it is the SMALLER so it will be -SUBTRACTED\n//        // SO: for each A[i] add it i times and subtract it (n - 1 - i) times\n//\n//        // ANOTHER WAY TO THINK ABOUT IT!!!!!!!\n//        // {1,2,3} cache distToAllPrev; so\n//        // distToAllPrev[i] = distToAllPrev[i - 1] + numPrev * distToPrevVal\n//        // distToAllPrev[3] = distToAllPrev[2] * dist_between_3_and_2\n//        // IDEA: dist from A[i] to all prev is the same as dist from A[i - 1] to all prev\n//        // but every time we ALSO add the distance from A[i - 1] to A[i]\n//\n//        long distToAllPrev = 0;\n//        for (int i = 1; i < nums.length; i++) {\n//            long distToPrev = (long) nums[i] - (long) nums[i - 1];\n//            long distToPrevWalked = (distToPrev * i) % mod;\n//            distToAllPrev = (distToPrevWalked + distToAllPrev) % mod;\n//            sum = (sum + distToAllPrev) % mod;\n//        }\n//\n////        for (int i = 0; i < n; i++) {\n////            long curr = i * (long) nums[i] - (n - 1 - i) * (long) nums[i];\n////            sum += curr;\n////            sum %= mod;\n////        }\n//\n//        return (int) (sum + mod) % mod;\n//    }\n\n\n    \n    public int sumDistance(int[] nums, String s, int d) {\n        int mod = (int)(1e9 + 7);\n        int n = nums.length;\n        long[] positions = new long[n];\n        for (int i = 0; i < n; i++) {\n            if (s.charAt(i) == \'R\') {\n                positions[i] = (long)nums[i] + d;\n            } else {\n                positions[i] = (long)nums[i] - d;\n            }\n        }\n        Arrays.sort(positions);\n        long res = 0L;\n        long preSum = 0L;\n        for (int i = 1; i < n; i++) {\n            long cur = preSum + i * (positions[i] - positions[i-1]);\n            res = (res + cur) % mod;\n            preSum = cur;\n        }\n        return (int)res;\n    }\n}\n\n```
['Java']