import copy
import itertools

N, X = map(int, input().split())
xlist = [int(i) for i in input().split()]

def pairwise(iterable):
    "s -> (s0,s1), (s1,s2), (s2, s3), ..."
    a, b = itertools.tee(iterable)
    next(b, None)
    return zip(a, b)
  
def calc_energy(path):
  ret = 0
  k = 0
  for pair in pairwise(path):
    ret += (k + 1) ** 2 * abs(pair[0] - pair[1])
    ret += X
    if pair[1] == 0:
      k = 0
    else:
      k += 1
  return ret

def movepath(cur, last):
  if not last:
    yield cur
  else:
    if cur[-1] == 0:
      for i in last:
        newlast = copy.copy(last)
        for ret in movepath(cur + [i], newlast):
          yield ret
    else:
      newlast = copy.copy(last)
      newlast.remove(cur[-1])
      for i in [0] + newlast:
       	for ret in movepath(cur + [i], newlast):
          yield ret

          
print(min(calc_energy(path) for path in movepath([0], xlist)))