WA in MAY20B COVID19

hello all , kindly help me through this, I am unable to know that in my solution where is the mistake so kindly help me please
COVID19 - Editorial

problem link : CodeChef: Practical coding for everyone

my solution:

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
static class FastReader {
BufferedReader br;
StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int t = scan.nextInt();
    while (t-- > 0) {
        int n  =scan.nextInt();
        long[] a = new long[n];
        for (int i=0;i<n;i++)
            a[i] = scan.nextLong();
        ArrayList<Long> x = new ArrayList<>();
        long count = 1;
        for(int i=0;i<n-1;i++){
            int j = i;
            if((a[j+1]-a[j])<=2&&(a[j+1]-a[j])>=0){
                count++;
            }
            else{
                x.add(count);
                count=1;
            }
        }
        if(count>1)
            x.add(count);
        Collections.sort(x);
        System.out.print(x.get(0)+" ");
        System.out.print(x.get(x.size()-1));
        System.out.println();
    }
}

}

This is an example test case where your code fails:

Input:
1
7
1 3 5 7 10 12 20
Expected Output:
1 4
Your Output
2 4

If you take a look at your code:

        if(count>1)
            x.add(count);

After the loop ended you have added a check such that if count is more than 1, then it will be added to the list x. But it should also be true for count==1

So the correct code will be:

        if(count>=1)
            x.add(count);

Note: I have not tried submitting it. I’m not fully sure about the rest of the code being completely correct.

@manjot1151 thank you so much.