#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;} template inline bool chmax(T& a,T b){ if(a inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; } //template end int dp[301000][20]={}; int main(){ int n; scanf("%d",&n); rep(i,0,n+1)rep(j,0,20)dp[i][j]=inf; dp[0][0]=0; vector a(n); rep(i,0,n)scanf("%d",&a[i]); rep(i,0,n){ rep(j,0,20)chmin(dp[i+1][j],dp[i][j]); rep(j,0,19){ if(dp[i][j]==0||(a[i]%dp[i][j]==0&&a[i]>dp[i][j])){ chmin(dp[i+1][j+1],a[i]); } } } rrep(j,19,-1)if(dp[n][j]!=inf){ printf("%d\n",j); return 0; } return 0; }