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.io.BufferedReader;
  import java.io.DataInputStream;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
  import java.util.HashSet;
  import java.util.InputMismatchException;
  import java.util.Set;
  import java.util.TreeSet;
  
  public class CF_1613 {
  
      // Utility functions
  
      public static final long M = 998244353;
  
      static long min_poison_damage = Long.MAX_VALUE;
  
      public static long fastPower(long a, long power, long m) {
          if(power == 0) return 1;
          if(power == 1) {
              return a % m;
          }
          long temp = fastPower(a, power >> 1, m);
          if(power % 2 == 0) {
              return (temp * temp) % m;
          }
          return (((temp * temp) % m) * a) % m;
      }
  
      public static void binarySearch(long[] arr, long l, long r, long target_damage) {
          if(l <= r) {
              long poison_duration = (l + r) / 2, damage = 0;
              for (int i = arr.length - 2; i >= 0; i--) {
                  damage += Math.min(arr[i + 1] - arr[i], poison_duration);
              }
              if (damage >= target_damage) {
                  min_poison_damage = Math.min(min_poison_damage, poison_duration);
                  binarySearch(arr, l, poison_duration - 1, target_damage);
              } else {
                  binarySearch(arr, poison_duration + 1, r, target_damage);
              }
          }
      }
  
      public static void mergeSort(int[] arr, int l, int r) {
          if(l != r) {
              int mid = (l+r)/2, i;
              mergeSort(arr, l, mid);
              mergeSort(arr, mid+1, r);
              int[] temp_l = new int[mid-l+1], temp_r = new int[r-mid];
              int index_l, index_r;
  
              //Copy contents to temporary arrays
  
              for(i = l, index_l = 0; i <= mid; i++, index_l++) {
                  temp_l[index_l] = arr[i];
              }
              for(i = mid+1, index_r = 0; i <= r; i++, index_r++) {
                  temp_r[index_r] = arr[i];
              }
  
              index_l = 0;
              index_r = 0;
  
              //Merge the temporary arrays in sorted form
              for(i = l; i <= r && index_l < temp_l.length && index_r < temp_r.length; i++) {
                  if(temp_l[index_l] <= temp_r[index_r]) {
                      arr[i] = temp_l[index_l++];
                  }
                  else {
                      arr[i] = temp_r[index_r++];
                  }
              }
  
              while(index_l < temp_l.length) {
                  arr[i] = temp_l[index_l++];
              }
  
              while(index_r < temp_r.length) {
                  arr[i] = temp_r[index_r++];
              }
          }
      }
  
      public static void printArray(PrintWriter out, int[] arr) {
          for (int j : arr) {
              out.print(j + " ");
          }
          out.println();
      }
  
      // Main execution function
  
      public static void main(String[] args) {
          InputReader in = new InputReader(System.in);
          PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
          int t = in.nextInt();
          int i;
          long[] total_subsequences = new long[(int)5e5+1], total_subsequences_1 = new long[(int)5e5 + 1];
          Set<Integer> visited;
          while(t-- > 0) {
              int n = in.nextInt(), inp;
              visited = new HashSet<>();
              long res = 0, count_one = 0;
              for(i = 0; i < n; i++) {
                  inp = in.nextInt();
                  if(!visited.contains(inp)) {
                      total_subsequences[inp] = 0;
                      total_subsequences_1[inp] = 0;
                  }
                  visited.add(inp);
                  if(inp == 1) {
                      count_one = ((2 * count_one) % M + 1) % M;
                  }
                  if(visited.contains(inp + 2)) {
                      total_subsequences_1[inp+2] = (total_subsequences_1[inp + 2] << 1) % M;
                  }
                  if(inp > 0) {
                      if(visited.contains(inp-1)) {
                          total_subsequences[inp] = (total_subsequences[inp-1] + (total_subsequences[inp] << 1) % M) % M;
                      }
                      if(visited.contains(inp-2)) {
                          total_subsequences_1[inp] = (total_subsequences[inp-2] + (total_subsequences_1[inp] << 1) % M) % M;
                      }
                  }
                  else
                      total_subsequences[0] = ((total_subsequences[0] * 2) % M + 1) % M;
              }
              for(Integer a: visited) {
                  res = (res + total_subsequences[a]) % M;
                  res = (res + total_subsequences_1[a]) % M;
              }
              res = (res + count_one) % M;
              out.println(res);
          }
          out.flush();
          out.close();
      }
  
      public static long temp_power_result;
  
      /**
       * If the result has already been calculated, return the existing result.
       */
      public static long powerMinusOne(long power, long m) {
          return temp_power_result > 0 ? temp_power_result : (fastPower(2, power, m) - 1) % m;
      }
  
      // Fast input class
  
      static class InputReader {
          private final InputStream stream;
          private final byte[] buf = new byte[1024];
          private int curChar;
          private int numChars;
          private SpaceCharFilter filter;
          private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  
          public InputReader(InputStream stream) {
              this.stream = stream;
          }
  
          public int read() {
              if (numChars==-1)
                  throw new InputMismatchException();
  
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  }
                  catch (IOException e) {
                      throw new InputMismatchException();
                  }
  
                  if(numChars <= 0)
                      return -1;
              }
              return buf[curChar++];
          }
  
          public String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              }
              catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
          public int nextInt() {
              int c = read();
  
              while(isSpaceChar(c))
                  c = read();
  
              int sgn = 1;
  
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
  
              int res = 0;
              do {
                  if(c<'0'||c>'9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              while (!isSpaceChar(c));
  
              return res * sgn;
          }
  
          public long nextLong() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              long res = 0;
  
              do {
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public double nextDouble() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              double res = 0;
              while (!isSpaceChar(c) && c != '.') {
                  if (c == 'e' || c == 'E')
                      return res * Math.pow(10, nextInt());
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              if (c == '.') {
                  c = read();
                  double m = 1;
                  while (!isSpaceChar(c)) {
                      if (c == 'e' || c == 'E')
                          return res * Math.pow(10, nextInt());
                      if (c < '0' || c > '9')
                          throw new InputMismatchException();
                      m /= 10;
                      res += (c - '0') * m;
                      c = read();
                  }
              }
              return res * sgn;
          }
  
          public String readString() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              StringBuilder res = new StringBuilder();
              do {
                  res.appendCodePoint(c);
                  c = read();
              }
              while (!isSpaceChar(c));
  
              return res.toString();
          }
  
          public boolean isSpaceChar(int c) {
              if (filter != null)
                  return filter.isSpaceChar(c);
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }
  
          public String next() {
              return readString();
          }
  
          public interface SpaceCharFilter {
              public boolean isSpaceChar(int ch);
          }
      }
  }