n=gets.to_i h=Hash.new([]) i=0 a=gets.split.map(&:to_i).sort b=[] 0.upto(n-2) do |i| if !b.include?(a[i]) (i+1).upto(n-1) do |ii| if a[ii]%a[i]==0 h[a[i]]+=[a[ii]] b+=[a[ii]] end end end end while true do i+=1 break if h=={} b=[] hh=Hash.new([]) h.each do |e,v| vl=v.length if vl==1 break end 0.upto(vl-2) do |i| if !b.include?(v[i]) (i+1).upto(vl-1) do |ii| if v[ii]%v[i]==0 hh[v[i]]+=[v[ii]] b+=[v[ii]] end end end end end h=hh.dup end p i