n,m=map(int,input().split())
a=list(map(int,input().split()))
fib=[0,1]
for i in range(n):
  fib.append(fib[i]+fib[i+1])
b=[]
for j in range(m):
  b.append(fib[a[m]-1])
ans=0
for t in range(m-1):
  ans+=(b[t]*b[t+1])%(10**9+1)
print(ans%(10**9+1))