import strutils,sequtils,algorithm,math type ameba = tuple[x : int , md : int] var N,D,T : int Ame = newSeq[ameba](0) X : seq[int] d : int ans : int64 (N, D, T) = stdin.readline.split.map(parseInt) X = stdin.readline.split.map(parseInt) for x in X: d = x mod D if x < 0: d += D Ame.add((x,d)) Ame = Ame.sortedByIt((it.md,it.x)) for i,a in Ame: if i == 0 or Ame[i - 1].md != a.md: ans += T else: ans += min((a.x - Ame[i - 1].x) div D - 1,T * 2) if i == Ame.high or Ame[i + 1].md != a.md: ans += T ans += 1 echo ans