description: British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that "every positive integer was one of his personal friends."
  
  It turns out that positive integers can also be friends with each other! You are given an array a of distinct positive integers. 
  
  Define a subarray a_i, a_{i+1}, …, a_j to be a friend group if and only if there exists an integer m ≥ 2 such that a_i mod m = a_{i+1} mod m = … = a_j mod m, where x mod y denotes the remainder when x is divided by y.
  
  Your friend Gregor wants to know the size of the largest friend group in a.
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅ 10^4). 
  
  Each test case begins with a line containing the integer n (1 ≤ n ≤ 2 ⋅ 10^5), the size of the array a.
  
  The next line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ {10}^{18}), representing the contents of the array a. It is guaranteed that all the numbers in a are distinct.
  
  It is guaranteed that the sum of n over all test cases is less than 2⋅ 10^5.
  
  Output
  
  Your output should consist of t lines. Each line should consist of a single integer, the size of the largest friend group in a.
  
  Example
  
  Input
  
  
  4
  5
  1 5 2 4 6
  4
  8 2 5 10
  2
  1000 2000
  8
  465 55 3 54 234 12 45 78
  
  
  Output
  
  
  3
  3
  2
  6
  
  Note
  
  In the first test case, the array is [1,5,2,4,6]. The largest friend group is [2,4,6], since all those numbers are congruent to 0 modulo 2, so m=2.
  
  In the second test case, the array is [8,2,5,10]. The largest friend group is [8,2,5], since all those numbers are congruent to 2 modulo 3, so m=3.
  
  In the third case, the largest friend group is [1000,2000]. There are clearly many possible values of m that work.
solution: import java.io.*;
  import java.util.*;
  
  public class Main {
      static PrintWriter pw;
      static Scanner sc;
      static long ceildiv(long x, long y) { return (x+y-1)/y; }
      static int mod(long x, int m) { return (int)((x%m+m)%m); }
      static void put(TreeMap<Long, Integer> map, Long p){if(map.containsKey(p)) map.replace(p, map.get(p)+1); else map.put(p, 1); }
      static void rem(TreeMap<Long, Integer> map, Long p){ if(map.get(p)==1) map.remove(p);else map.replace(p, map.get(p)-1); }
      static void printf(double x, int dig){ String s="%."+dig+"f"; pw.printf(s, x); }
      static int Int(boolean x){ return x?1:0; }
      static final int inf=(int)1e9, mod= inf + 7;
      static final long infL=inf*1l*inf;
      static final double eps=1e-9;
      public static long gcd(long x, long y) { return y==0? x: gcd(y, x%y); }
      public static void main(String[] args) throws Exception {
          sc = new Scanner(System.in);
          pw = new PrintWriter(System.out);
          int t = sc.nextInt();
          while (t-- > 0)
              testcase();
          pw.close();
      }
  
      static void testcase() throws IOException {
          int n = sc.nextInt();
          long[] arr = sc.nextLongArr(n);
          Solver solver = new Solver(n);
          solver.add(arr[0]);
          int ans = 1;
          for (int i = 0, j=0; j<n;) {
              if(solver.getGCD() != 1){
                  ans = Math.max(ans, j-i+1);
                  if(j < n-1)
                      solver.add(arr[++j]);
                  else
                      break;
              }else{
                  solver.remove(arr[i++]);
              }
          }
          pw.println(ans);
      }
  
      static class Solver{
          SegmentTree diff;
          int diffSize;
          TreeMap<Long, Integer> values;
          HashMap<Long, Queue<Integer>> diffIdx;
          Queue<Integer> freeIdx;
          public Solver(int n){
              diff = new SegmentTree(new int[n]);
              values = new TreeMap<>();
              diffSize = 0;
              diffIdx = new HashMap<>();
              freeIdx = new LinkedList<>();
          }
  
          public void add(long x){
              put(values, x);
              if(values.get(x) == 1){
                  Long more = values.ceilingKey(x+1);
                  Long less = values.floorKey(x-1);
                  if(more != null)
                      addToDiff(more - x);
                  if(less != null)
                      addToDiff(x - less);
                  if(more != null && less != null)
                      removeFromDiff(more - less);
              }
          }
  
          public void remove(long x){
              rem(values, x);
              if(!values.containsKey(x)){
                  Long more = values.ceilingKey(x+1);
                  Long less = values.floorKey(x-1);
                  if(more != null)
                      removeFromDiff(more - x);
                  if(less != null)
                      removeFromDiff(x - less);
                  if(more != null && less != null)
                      addToDiff(more - less);
              }
          }
  
          public void addToDiff(long x){
              if(!freeIdx.isEmpty()){
                  int idx = freeIdx.poll();
                  diff.updateValue(idx, x);
                  if(!diffIdx.containsKey(x))
                      diffIdx.put(x, new LinkedList<>());
                  diffIdx.get(x).add(idx);
                  return;
              }
              diff.updateValue(diffSize, x);
              if(!diffIdx.containsKey(x))
                  diffIdx.put(x, new LinkedList<>());
              diffIdx.get(x).add(diffSize);
              diffSize++;
          }
  
          public void removeFromDiff(long x){
              int idx = diffIdx.get(x).poll();
              diff.updateValue(idx, 0);
              freeIdx.add(idx);
          }
  
          public long getGCD(){
              return diff.tree[0];
          }
      }
  
      static class SegmentTree {
          long[] arr, tree;
          int n;
          public SegmentTree(int[] arr){
              int N = arr.length;
              n = 1;
              while(n < N)
                  n <<= 1;
              this.arr = new long[n];
              for (int i = 0; i < N; i++)
                  this.arr[i] = arr[i];
              tree = new long[2*n -1];
              build(0);
          }
  
          public long build(int i){
              if(i >= n-1)
                  return tree[i] = arr[i-n+1];
              return tree[i] = gcd(build(2*i +1), build(2*i + 2));
          }
  
          public long getGCD(int l, int r){
              return getGCD(0, 0, n-1, l, r);
          }
  
          public long getGCD(int node, int i, int j, int l, int r){
              if(i>=l && j<=r)
                  return tree[node];
              if(i>r || j<l)
                  return 0;
              int mid = (i+j)/2, left = 2*node + 1, right = 2*node + 2;
              return gcd(getGCD(left, i, mid, l, r), getGCD(right, mid+1, j, l, r));
          }
  
          public void updateValue(int idx, long val){
              int i = n-1 + idx;
              tree[i] = val;
              arr[idx] = val;
              while(i >= 1){
                  i = (i-1)/2;
                  tree[i] = gcd(tree[i*2 + 1], tree[i*2 + 2]);
              }
          }
      }
  
      static void printArr(int[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
      static void printArr(long[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
      static void printArr(double[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
      static void printArr(Integer[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
      static void printArr(List list) {
          for (int i = 0; i < list.size() - 1; i++)
              pw.print(list.get(i)+" ");
          pw.println(list.get(list.size()-1));
      }
      static void printArr(boolean[] arr) {
          StringBuilder sb=new StringBuilder();
          for(boolean b: arr)
              sb.append(Int(b));
          pw.println(sb);
      }
      static class Scanner {
          StringTokenizer st;
          BufferedReader br;
          public Scanner(InputStream s) {
              br = new BufferedReader(new InputStreamReader(s));
          }
  
          public Scanner(FileReader r) {
              br = new BufferedReader(r);
          }
  
          public String next() throws IOException {
              while (st == null || !st.hasMoreTokens())
                  st = new StringTokenizer(br.readLine());
              return st.nextToken();
          }
  
          public int nextInt() throws IOException {
              return Integer.parseInt(next());
          }
  
          public long nextLong() throws IOException {
              return Long.parseLong(next());
          }
  
          public String nextLine() throws IOException {
              return br.readLine();
          }
  
          public double nextDouble() throws IOException {
              return Double.parseDouble(next());
          }
          public int[] nextDigits() throws IOException{
              String s=nextLine();
              int[] arr=new int[s.length()];
              for(int i=0; i<arr.length; i++)
                  arr[i]=s.charAt(i)-'0';
              return arr;
          }
          public int[] nextArr(int n) throws IOException {
              int[] arr = new int[n];
              for (int i = 0; i < arr.length; i++)
                  arr[i] = nextInt();
              return arr;
          }
          public Integer[] nextsort(int n) throws IOException{
              Integer[] arr=new Integer[n];
              for(int i=0; i<n; i++)
                  arr[i]=nextInt();
              return arr;
          }
          public Pair nextPair() throws IOException{
              return new Pair(nextInt(), nextInt());
          }
          public long[] nextLongArr(int n) throws IOException{
              long[] arr=new long[n];
              for (int i = 0; i < n; i++)
                  arr[i]=sc.nextLong();
              return arr;
          }
          public Pair[] nextPairArr(int n) throws IOException{
              Pair[] arr=new Pair[n];
              for(int i=0; i<n; i++)
                  arr[i]=nextPair();
              return arr;
          }
          public boolean hasNext() throws IOException {
              return (st!=null && st.hasMoreTokens()) || br.ready();
          }
      }
      static class Pair implements Comparable<Pair> {
          int x;
          int y;
  
          public Pair(int x, int y) {
              this.x = x;
              this.y = y;
          }
  
          public Pair(Map.Entry<Integer, Integer> a) {
              x = a.getKey();
              y = a.getValue();
          }
  
          public boolean inRange(int mid){
              return mid>=x && mid<=y;
          }
  
          public boolean contains(int a) {
              return x == a || y == a;
          }
  
          public int hashCode() {
              return (this.x * 1000000000 + this.y);
          }
  
          public int compareTo(Pair p) {
              return Integer.compare(x, p.x);
          }
  
          public boolean equals(Object obj) {
              if (obj == null) {
                  return false;
              }
              if (this.getClass() != obj.getClass()) {
                  return false;
              }
              Pair p = (Pair) obj;
              return this.x == p.x && this.y == p.y;
          }
  
          public Pair clone() {
              return new Pair(x, y);
          }
  
          public String toString() {
              return this.x + " " + this.y;
          }
  
          public void add(Pair p) {
              x += p.x;
              y += p.y;
          }
      }
  }