human
Longest sub | Function to return the length of the longest required sub - sequence.
Sort the array.
To store the resultant length.
If array contains only one element then it divides itself.
Every element divides itself.
Count for all numbers which are lesser than a [ i ].
If a [ i ] % a [ j ] then update the maximum subsequence length , dp [ i ] = max ( dp [ i ] , 1 + dp [ j ] ) where j is in the range [ 0 , i - 1 ].
If array contains only one element then i = j which doesn 't satisfy the condition.
Driver code"
How can the above be solved in Python?

Give me a code to longest sub and the other steps required?
assistant
#Here is code to longest sub and the other steps required.
 def find ( n , a ) :
	a . sort ( ) ;
	res = 1 ;
	dp = [ 0 ] * n ;
	dp [ 0 ] = 1 ;
	for i in range ( 1 , n ) :
		dp [ i ] = 1 ;
		for j in range ( i ) :
			if ( a [ i ] % a [ j ] == 0 ) :
				dp [ i ] = max ( dp [ i ] , 1 + dp [ j ] ) ;
		res = max ( res , dp [ i ] ) ;
	if ( res == 1 ) :
		return - 1
	else :
		return res ;
if __name__ == " _ _ main _ _ " :
	a = [ 2 , 4 , 6 , 1 , 3 , 11 ] ;
	n = len ( a ) ;
	print ( find ( n , a ) ) ;