Write an expression for Best(i) in terms of Best(j) with j<i, with base case Best(1) = 1. Solve this recurrence using dynamic programming.
l=[]
s=input()
s=int(s)
st=[]
for y in range(s):
l.append(int(input()))
st.append(0)
def best(k):
st[0]=1
for i in range(0,len(l)):
m=1
for j in range(0,i):
if(k[i]%k[j]==0):
m=max(m,st[j]+1)
st[i]=m
best(l)
print (max(st))
l=[]
s=input()
s=int(s)
st=[]
for y in range(s):
l.append(int(input()))
st.append(0)
def best(k):
st[0]=1
for i in range(0,len(l)):
m=1
for j in range(0,i):
if(k[i]%k[j]==0):
m=max(m,st[j]+1)
st[i]=m
best(l)
print (max(st))