import itertools
def an(n,d,a):
    kumi=list(itertools.combinations(range(0,n), 2))
    cost=[0]*len(kumi)
    z=0
    
  
    for i,j in kumi:
        cost[z]=((abs(i-j)*d+a[i]+a[j]),(i,j))
        z+=1
    
    cost.sort()

    ans=0

    ki=[]
    for i in range(len(cost)):
        hen1=cost[i][1][0]
        hen2=cost[i][1][1]

        if hen1 in ki and hen2 in ki:
            pass
        else:

            ans+=cost[i][0]

        ki.append(hen1)
        ki.append(hen2)
        ki=list(set(ki))
        if len(ki)==n:
            break


    return ans


n,d=map(int,input().split())
print(an(n,d,[int(i) for i in input().split()]))