def poly(l, x): s = 0 for i,v in enumerate(l): s += v * x ** i return s l = map(int, input(">>>").split()) x = int(input(">>>")) print(poly(l, x))