1. #include <bits/stdc++.h>
  2. using namespace std;
  3. /*
  4. ------------------------Input Checker----------------------------------
  5. */
  6. long long readInt(long long l,long long r,char endd){
  7. long long x=0;
  8. int cnt=0;
  9. int fi=-1;
  10. bool is_neg=false;
  11. while(true){
  12. char g=getchar();
  13. if(g=='-'){
  14. assert(fi==-1);
  15. is_neg=true;
  16. continue;
  17. }
  18. if('0'<=g && g<='9'){
  19. x*=10;
  20. x+=g-'0';
  21. if(cnt==0){
  22. fi=g-'0';
  23. }
  24. cnt++;
  25. assert(fi!=0 || cnt==1);
  26. assert(fi!=0 || is_neg==false);
  27. assert(!(cnt>19 || ( cnt==19 && fi>1) ));
  28. } else if(g==endd){
  29. if(is_neg){
  30. x= -x;
  31. }
  32. if(!(l <= x && x <= r))
  33. {
  34. cerr << l << ' ' << r << ' ' << x << '\n';
  35. assert(1 == 0);
  36. }
  37. return x;
  38. } else {
  39. assert(false);
  40. }
  41. }
  42. }
  43. string readString(int l,int r,char endd){
  44. string ret="";
  45. int cnt=0;
  46. while(true){
  47. char g=getchar();
  48. assert(g!=-1);
  49. if(g==endd){
  50. break;
  51. }
  52. cnt++;
  53. ret+=g;
  54. }
  55. assert(l<=cnt && cnt<=r);
  56. return ret;
  57. }
  58. long long readIntSp(long long l,long long r){
  59. return readInt(l,r,' ');
  60. }
  61. long long readIntLn(long long l,long long r){
  62. return readInt(l,r,'\n');
  63. }
  64. string readStringLn(int l,int r){
  65. return readString(l,r,'\n');
  66. }
  67. string readStringSp(int l,int r){
  68. return readString(l,r,' ');
  69. }
  70. /*
  71. ------------------------Main code starts here----------------------------------
  72. */
  73. const int MAX_T = 1e5;
  74. const int MAX_N = 1e5;
  75. const int MAX_SUM_LEN = 1e5;
  76. #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  77. #define ff first
  78. #define ss second
  79. #define mp make_pair
  80. #define ll long long
  81. #define rep(i,n) for(int i=0;i<n;i++)
  82. #define rev(i,n) for(int i=n;i>=0;i--)
  83. #define rep_a(i,a,n) for(int i=a;i<n;i++)
  84. #define pb push_back
  85. ll sum_n = 0, sum_m = 0;
  86. int max_n = 0, max_m = 0;
  87. int yess = 0;
  88. int nos = 0;
  89. int total_ops = 0;
  90. ll mod = 998244353;
  91.  
  92. using ii = pair<ll,ll>;
  93.  
  94.  
  95.  
  96. void solve(){
  97.  
  98. int n = readIntLn(2,3e5);
  99. sum_n+=n;
  100.  
  101. int g = 0;
  102. int a[n], pg[n], sg[n];
  103.  
  104. rep(i,n){
  105. if(i<n-1) a[i] = readIntSp(1,1e9);
  106. else a[i] = readIntLn(1,1e9);
  107.  
  108. g = __gcd(g,a[i]);
  109. pg[i] = g;
  110. }
  111.  
  112. int curr = 0, cnt = 0;
  113. rev(i,n-1){
  114. int tmp = curr;
  115. if(i>0) tmp = __gcd(tmp, pg[i-1]);
  116.  
  117. if(tmp>g || g>1) cnt++;
  118. curr = __gcd(curr, a[i]);
  119. }
  120.  
  121. cout<<cnt<<'\n';
  122. }
  123.  
  124.  
  125. signed main()
  126. {
  127.  
  128. #ifndef ONLINE_JUDGE
  129. freopen("input.txt", "r" , stdin);
  130. freopen("output.txt", "w" , stdout);
  131. #endif
  132. fast;
  133. int t = 1;
  134. t = readIntLn(1,5e4);
  135. for(int i=1;i<=t;i++)
  136. {
  137. solve();
  138. }
  139. assert(getchar() == -1);
  140. assert(sum_n<=3e5);
  141. cerr<<"SUCCESS\n";
  142. cerr<<"Tests : " << t << '\n';
  143. cerr<<"Sum of lengths : " << sum_n<<'\n';
  144. //cerr<<"Maximum answer : " << max_n <<'\n';
  145. // // cerr<<"Total operations : " << total_ops << '\n';
  146. // cerr<<"Answered yes : " << yess << '\n';
  147. // cerr<<"Answered no : " << nos << '\n';
  148.  
  149. cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
  150. }