import sys readline = sys.stdin.buffer.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prn = lambda x: print(*x, sep='\n') def Kitamasa(C, X, k, e0=0, e1=1, mod=10**9+7): ''' 0-indexed calc X[k] ''' n = len(X) def _plus1(g): ret = [(g[i-1] + g[-1] * C[i]) % mod for i in range(n)] ret[0] = g[-1] * C[0] % mod return ret def _mult2(g): ret = [e0]*(2 * n - 1) for i in range(n): for j in range(n): ret[i + j] = (ret[i + j] + g[i] * g[j]) % mod for i in range(2*n-2, n-1, -1): for j in range(n): ret[i + j - n] = (ret[i + j - n] + ret[i] * C[j]) % mod return ret[:n] g = [e0]*n g[0] = e1 t = k.bit_length() for i in range(t-1, -1, -1): g = _mult2(g) if k & (1<>1)) return d[x] cur = [0] * k for i in range(n): # print(i, f[i], g[i]) cur = plus1(cur) cur[0] += f[i] for x in g[i]: neg = search(x) for j in range(k): cur[j] -= neg[j] # print(cur, i, f[i], g[i]) print(sum(cur[j]*a[j] for j in range(k)) % mod) # cur = [1, 0] # for i in range(10): # cur = plus1(cur) # print(cur, search(i+1)) return solve()