It's the annual military parade, and all the soldier snakes have arrived at the parade arena, But they aren't standing properly. The entire parade must be visible from the main podium, and all the snakes must be in a line. But the soldiers are lazy, and hence you must tell the soldiers to move to their new positions in such a manner that the total movement is minimized.
Formally, the entire parade strip can be thought of as the integer line. There are N snakes, where each snake is a line segment of length L. The i-th snake is initially at the segment [Si, Si + L]. The initial positions of the snakes can overlap. The only segment of the strip visible from the podium is [A, B], and hence all the snakes should be moved so that all of them are visible from the podium. They should also all be in a line without gaps and every consecutive pair touching each other. In other words, they should occupy the segments [X, X + L], [X + L, X + 2*L], ... , [X + (N-1)*L, X + N*L], for some X, such that A ≤ X ≤ X + N*L ≤ B. You are guaranteed that the visible strip is long enough to fit all the snakes.

If a snake was initially at the position [X1, X1 + L] and finally is at the position [X2, X2 + L], then the snake is said to have moved a distance of |X2 - X1|. The total distance moved by the snakes is just the summation of this value over all the snakes. You need to move the snakes in such a manner that it satisfies all the conditions mentioned above, as well as minimize the total distance. You should output the minimum total distance achievable.

-----Input-----
- The first line contains a single integer, T, the number of testcases. The description of each testcase follows.
- The first line of each testcase contains four integers, N, L, A and B, where N denotes the number of snakes, L denotes the length of each snake, and [A, B] is the segment visible from the podium.
- The next line contains N integers, the i-th of which is Si. This denotes that the i-th snake is initially in the segment [Si, Si + L].

-----Output-----
- For each testcase, output a single integer in a new line: the minimum total distance achievable.

-----Constraints-----
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 105
- 1 ≤ Si ≤ 109
- 1 ≤ L ≤ 109
- 1 ≤ A ≤ B ≤ 109
- N * L ≤ B - A

-----Example-----
Input:
2
3 4 11 23
10 11 30
3 4 11 40
10 11 30

Output:
16
16

-----Explanation-----
In the first testcase, the three snakes are initially at segments [10, 14], [11, 15], and [30, 34]. One optimal solution is to move the first snake which was at [10, 14] to [15, 19] and the third snake which was at [30, 34] to [19, 23]. After this, the snakes would form a valid parade because they will be from [11, 15], [15, 19] and [19, 23]. Hence they are all in a line without any gaps in between them, and they are all visible, because they all lie in the visible segment, which is [11, 23].
The distance traveled by the first snake is |15 - 10| = 5, by the second snake is |11 - 11| = 0 and by the third snake is |19 - 30| = 11. Hence the total distance traveled is 5 + 0 + 11 = 16. This is the best that you can do, and hence the answer is 16.
In the second testcase, only the visible segment has increased. But you can check that the same final configuration as in the first subtask is still optimal here. Hence the answer is 16.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'T = eval(input())\ndef diff(seqA, seqB):\n d = 0\n for i in range(len(seqA)):\n  d += abs(seqA[i]- seqB[i])\n return d\ndef gen_seq(start, L, N):\n return [start + i*L for i in range(N)]\n\n\ndef binSearch(s,e,ll,L,N):\n # find the middle item\n if s==e:\n  return diff(ll,gen_seq(s,L,N))\n\n mid = int((s+e)/2)\n if diff(ll,gen_seq(mid,L,N)) > diff(ll,gen_seq(mid+1,L,N)):\n  # we go left \n  return binSearch(mid+1,e,ll,L,N)\n else:\n  return binSearch(s,mid,ll,L,N)\n  #we go right\n\n\n\n\nwhile T>0:\n T-=1\n\n N,L,A,B = list(map(int,input().split()))\n ll = list(map(int,input().split()))\n ll = sorted(ll)\n\n lastpossible = B - L\n startA = A\n\n # the one for which the last one remains there in range \n lastA = int((B-L) - (N-1)*L)\n # print "N %d L %d A %d B %d" % (N,L,A,B)\n # print "startA %d, lastA %d" %(startA,lastA)\n # print(lastA - startA)/(1.0*L)\n\n seq_cost_beg = diff(ll,gen_seq(startA,L,N)) \n seq_cost_end = diff(ll,gen_seq(lastA,L,N)) \n\n\n # print min(seq_cost_beg, seq_cost_end)\n\n print(binSearch(startA,lastA,ll,L,N))\n\n\n\n\n # for j in range(startA,lastA+1):\n #     leg_seq = gen_seq(j,L,N)\n #     print ll,leg_seq,diff(ll,leg_seq)   \n # print "-------------"\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 16925