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.lang.*;
  import java.io.*;
  
  public class Main {
      public static long mod = 1000000007;
      public static long mod2 = 998244353;
  
      public static void main(String[] args) throws java.lang.Exception {
          Reader sc = new Reader();
          FastNum in = new FastNum(System.in);
          PrintWriter out = new PrintWriter(System.out);
  //        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  
          int tests = in.nextInt();
          for (int test = 1; test <= tests; test++) {
              int n = in.nextInt();
              int[] a = new int[n];
              for (int i = 0; i < n; i++) a[i] = in.nextInt();
              long[][] dp = new long[n+10][2];
              dp[0][0] = 1;
  
              for(int x : a) {
                  // x - 1
                  if(x > 0)  dp[x-1][1] = (dp[x-1][0] + 2 * dp[x-1][1]) % mod2;
                  // x + 1
                  dp[x+1][0] = (2 * dp[x+1][0]) % mod2;
                  dp[x+1][1] = (2 * dp[x+1][1]) % mod2;
                  // x
                  dp[x+1][0] = (dp[x][0] + dp[x+1][0]) % mod2;
              }
  
              long ans = -1;
              for (int i = 0; i < n + 3; i++) {
                  ans = (ans + dp[i][0] + dp[i][1]) % mod2;
              }
              out.println(ans);
  
          }
  
          out.flush();
      }
  
      public static long power(long a, long b) {
          if (b == 0)
              return 1;
          long answer = power(a, b / 2) % mod;
          answer = (answer * answer) % mod;
          if (b % 2 != 0)
              answer = (answer * a) % mod;
          return answer;
      }
  
      public static void swap(int x, int y) {
          int t = x;
          x = y;
          y = t;
      }
  
      public static long min(long a, long b) {
          if (a < b) return a;
          return b;
      }
  
      public static long divide(long a, long b) {
          return (a % mod * (power(b, mod - 2) % mod)) % mod;
      }
  
      public static long nCr(long n, long r) {
          long answer = 1;
          long k = min(r, n - r);
          for (long i = 0; i < k; i++) {
              answer = (answer % mod * (n - i) % mod) % mod;
              answer = divide(answer, i + 1);
          }
          return answer % mod;
      }
  
      public static boolean plaindrome(String str) {
          StringBuilder sb = new StringBuilder();
          sb.append(str);
          return (str.equals((sb.reverse()).toString()));
      }
  
      public static class Pair {
          int a;
          int b;
  
          Pair(int s, int e) {
              a = s;
              b = e;
          }
      }
  
      static class Assert {
          static void check(boolean e) {
              if (!e) {
                  throw new AssertionError();
              }
          }
      }
  
      static class FastNum implements AutoCloseable {
  
          InputStream is;
          byte buffer[] = new byte[1 << 16];
          int size = 0;
          int pos = 0;
  
          FastNum(InputStream is) {
              this.is = is;
          }
  
          int nextChar() {
              if (pos >= size) {
                  try {
                      size = is.read(buffer);
                  } catch (IOException e) {
                      throw new IOError(e);
                  }
                  pos = 0;
                  if (size == -1) {
                      return -1;
                  }
              }
              Assert.check(pos < size);
              int c = buffer[pos] & 0xFF;
              pos++;
              return c;
          }
  
          int nextInt() {
              int c = nextChar();
              while (c == ' ' || c == '\r' || c == '\n' || c == '\t') {
                  c = nextChar();
              }
              if (c == '-') {
                  c = nextChar();
                  Assert.check('0' <= c && c <= '9');
                  int n = -(c - '0');
                  c = nextChar();
                  while ('0' <= c && c <= '9') {
                      int d = c - '0';
                      c = nextChar();
                      Assert.check(n > Integer.MIN_VALUE / 10
                              || n == Integer.MIN_VALUE / 10 && d <= -(Integer.MIN_VALUE % 10));
                      n = n * 10 - d;
                  }
                  return n;
              } else {
                  Assert.check('0' <= c && c <= '9');
                  int n = c - '0';
                  c = nextChar();
                  while ('0' <= c && c <= '9') {
                      int d = c - '0';
                      c = nextChar();
                      Assert.check(
                              n < Integer.MAX_VALUE / 10 || n == Integer.MAX_VALUE / 10 && d <= Integer.MAX_VALUE % 10);
                      n = n * 10 + d;
                  }
                  return n;
              }
          }
  
          @Override
          public void close() {
          }
      }
  
  
      static class Reader {
          final private int BUFFER_SIZE = 1 << 16;
          private final DataInputStream din;
          private final byte[] buffer;
          private int bufferPointer, bytesRead;
  
          public Reader() {
              din = new DataInputStream(System.in);
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
  
          public Reader(String file_name) throws IOException {
              din = new DataInputStream(new FileInputStream(file_name));
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
  
          public String readLine() throws IOException {
              byte[] buf = new byte[64]; // line length
              int cnt = 0, c;
              while ((c = read()) != -1) {
                  if (c == '\n')
                      break;
                  buf[cnt++] = (byte) c;
              }
              return new String(buf, 0, cnt);
          }
  
          public int nextInt() throws IOException {
              int ret = 0;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
  
              if (neg)
                  return -ret;
              return ret;
          }
  
          public long nextLong() throws IOException {
              long ret = 0;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              }
              while ((c = read()) >= '0' && c <= '9');
              if (neg)
                  return -ret;
              return ret;
          }
  
          public double nextDouble() throws IOException {
              double ret = 0, div = 1;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
  
              do {
                  ret = ret * 10 + c - '0';
              }
              while ((c = read()) >= '0' && c <= '9');
  
              if (c == '.') {
                  while ((c = read()) >= '0' && c <= '9') {
                      ret += (c - '0') / (div *= 10);
                  }
              }
  
              if (neg)
                  return -ret;
              return ret;
          }
  
          private void fillBuffer() throws IOException {
              bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
              if (bytesRead == -1)
                  buffer[0] = -1;
          }
  
          private byte read() throws IOException {
              if (bufferPointer == bytesRead)
                  fillBuffer();
              return buffer[bufferPointer++];
          }
  
          public void close() throws IOException {
              if (din == null)
                  return;
              din.close();
          }
      }
  }
  