description: Let's call a sequence of integers x_1, x_2, ..., x_k MEX-correct if for all i (1 ≤ i ≤ k) |x_i - \operatorname{MEX}(x_1, x_2, ..., x_i)| ≤ 1 holds. Where \operatorname{MEX}(x_1, ..., x_k) is the minimum non-negative integer that doesn't belong to the set x_1, ..., x_k. For example, \operatorname{MEX}(1, 0, 1, 3) = 2 and \operatorname{MEX}(2, 1, 5) = 0.
  
  You are given an array a consisting of n non-negative integers. Calculate the number of non-empty MEX-correct subsequences of a given array. The number of subsequences can be very large, so print it modulo 998244353. 
  
  Note: a subsequence of an array a is a sequence [a_{i_1}, a_{i_2}, ..., a_{i_m}] meeting the constraints 1 ≤ i_1 < i_2 < ... < i_m ≤ n. If two different ways to choose the sequence of indices [i_1, i_2, ..., i_m] yield the same subsequence, the resulting subsequence should be counted twice (i. e. two subsequences are different if their sequences of indices [i_1, i_2, ..., i_m] are not the same).
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.
  
  The first line of each test case contains a single integer n (1 ≤ n ≤ 5 ⋅ 10^5).
  
  The second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ n).
  
  The sum of n over all test cases doesn't exceed 5 ⋅ 10^5.
  
  Output
  
  For each test case, print a single integer — the number of non-empty MEX-correct subsequences of a given array, taken modulo 998244353.
  
  Example
  
  Input
  
  
  4
  3
  0 2 1
  2
  1 0
  5
  0 0 0 0 0
  4
  0 1 2 3
  
  
  Output
  
  
  4
  2
  31
  7
  
  Note
  
  In the first example, the valid subsequences are [0], [1], [0,1] and [0,2].
  
  In the second example, the valid subsequences are [0] and [1].
  
  In the third example, any non-empty subsequence is valid. 
solution: import java.util.*;
  import java.io.*;
  
  ////***************************************************************************
   /* public class E_Gardener_and_Tree implements Runnable{
  
         public static void main(String[] args) throws Exception {
          new Thread(null, new E_Gardener_and_Tree(), "E_Gardener_and_Tree", 1<<28).start();
         }
      public void run(){
           WRITE YOUR CODE HERE!!!!
           JUST WRITE EVERYTHING HERE WHICH YOU WRITE IN MAIN!!!
         }
  
    }
  */
  /////**************************************************************************
  
  
  public class D_MEX_Sequences{
      public static void main(String[] args) {
          FastScanner s= new FastScanner();
          //PrintWriter out=new PrintWriter(System.out);
          //end of program
          //out.println(answer);
          //out.close();
          StringBuilder res = new StringBuilder();
          long mod=998244353 ;
          int t=s.nextInt();
          int p=0;
        //  System.out.println("mod"+ mod);
          while(p<t){
          int n=s.nextInt();
  
          long array[]= new long[n];
          long count[]= new long[n+5];
          for(int i=0;i<n;i++){
              array[i]=s.nextLong();
              count[(int)array[i]]++;
          }
          long ans=0;
          ans+=(power(2,count[1],mod));
          ans--;
          long nice[]= new long[n+5];
          long end[]= new long[n+5];
          for(int i=0;i<n;i++){
              nice[(int)array[i]]++;
              long hh=0;
              if(array[i]==0){
                    hh=(end[0]+1)%mod;
                   end[0]=(end[0]+(hh))%mod;
                   ans=(ans+hh)%mod;
                  // System.out.println(hh);
  
  
              }
              else{
                  hh=((end[(int)(array[i])]+end[(int)(array[i]-1)]))%mod;
                 end[(int)array[i]]=((end[(int)(array[i])]+hh))%mod;
                 ans=(ans+hh)%mod;
  
              }
              long jj=1;
              if(array[i]-1>=0){
                  jj=end[(int)(array[i]-1)];
              }
             // System.out.println("hh "+hh);
              long cc1=count[(int)array[i]]-nice[(int)(array[i])];
            //  System.out.println("cc1 "+cc1);
              long cc2=count[(int)array[i]+2]-nice[(int)(array[i]+2)];
             // System.out.println("cc2 "+cc2);
              long kk1=power(2,(cc1+cc2),mod);
              kk1--;
              long kk2=power(2,cc1,mod);
              kk2--;
              long kk3=(kk1-kk2+mod)%mod;
              long yo1=(jj*kk3)%mod;
              ans=(ans+yo1)%mod;
            //  System.out.println("ans "+ans);
              
  
  
          }
          res.append(ans+" \n");
          p++;
      }
      System.out.println(res);
  
  
  
  
      }
  
      static long power(long x, long y, long p)
      {
        long res = 1; // Initialize result
     
        x = x % p; // Update x if it is more than or
        // equal to p
     
        if (x == 0)
          return 0; // In case x is divisible by p;
     
        while (y > 0)
        {
     
          // If y is odd, multiply x with result
          if ((y & 1) != 0)
            res = (res * x) % p;
     
          // y must be even now
          y = y >> 1; // y = y/2
          x = (x * x) % p;
        }
        return res;
      }
     
      static class FastScanner {
  		BufferedReader br;
  		StringTokenizer st;
   
  		public FastScanner(String s) {
  			try {
  				br = new BufferedReader(new FileReader(s));
  			} catch (FileNotFoundException e) {
  				// TODO Auto-generated catch block
  				e.printStackTrace();
  			}
  		}
   
  		public FastScanner() {
  			br = new BufferedReader(new InputStreamReader(System.in));
  		}
   
  		String nextToken() {
  			while (st == null || !st.hasMoreElements()) {
  				try {
  					st = new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					// TODO Auto-generated catch block
  					e.printStackTrace();
  				}
  			}
  			return st.nextToken();
  		}
   
  		int nextInt() {
  			return Integer.parseInt(nextToken());
  		}
   
  		long nextLong() {
  			return Long.parseLong(nextToken());
  		}
   
  		double nextDouble() {
  			return Double.parseDouble(nextToken());
  		}
  	}
  
  
  
  
  }