Use sum to find the differences
\nconst int MOD = 1000000007;\nclass Solution {\n  int sumDistance(List<int> nums, String s, int d) {\n    List<int> finals = [];\n    for (int i = 0; i < nums.
```\nconst int MOD = 1000000007;\nclass Solution {\n  int sumDistance(List<int> nums, String s, int d) {\n    List<int> finals = [];\n    for (int i = 0; i < nums.length; i++)\n      finals.add((s[i] == \'L\') ? nums[i] - d : nums[i] + d);\n    finals.sort();\n\n    int res = 0;\n\n    int right_sum = finals.reduce((value, element) => value + element);\n    int left_sum = 0;\n    \n    for (int i = 0; i < finals.length; i++) {\n      res = (res +\n          right_sum - (finals.length - i) * finals[i] ) % MOD\n      ;\n      \n      right_sum -= finals[i];\n      left_sum += finals[i];\n    }\n    return res;\n  }\n}\n```
['Dart']