# Enter your code here. Read input from STDIN. Print output to STDOUT n,k=map(int,raw_input().split()) bulbs=sorted(map(int,raw_input().split())) weight=None cost=0 for bulb in bulbs: if weight is None or bulb-weight > k: weight=bulb cost=cost+weight print cost