The R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly affects the result. The higher the speed of the Internet is, the faster the participant will find the necessary information. Therefore, before the competition started, each computer had its maximum possible data transfer speed measured. On the i-th computer it was ai kilobits per second.There will be k participants competing in the championship, each should get a separate computer. The organizing company does not want any of the participants to have an advantage over the others, so they want to provide the same data transfer speed to each participant's computer. Also, the organizers want to create the most comfortable conditions for the participants, so the data transfer speed on the participants' computers should be as large as possible.The network settings of the R1 company has a special option that lets you to cut the initial maximum data transfer speed of any computer to any lower speed. How should the R1 company configure the network using the described option so that at least k of n computers had the same data transfer speed and the data transfer speed on these computers was as large as possible?

The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 100) — the number of computers and the number of participants, respectively. In the second line you have a space-separated sequence consisting of n integers: a1, a2, ..., an (16 ≤ ai ≤ 32768); number ai denotes the maximum data transfer speed on the i-th computer.

Print a single integer — the maximum Internet speed value. It is guaranteed that the answer to the problem is always an integer.

NoteIn the first test case the organizers can cut the first computer's speed to 30 kilobits. Then two computers (the first and the third one) will have the same speed of 30 kilobits. They should be used as the participants' computers. This answer is optimal.

function main() {

    var temp = readline().split(' ').map(Number);
    var n = temp[0],
        k = temp[1];

    var arr = readline().split(' ').map(Number);

    arr.sort(function (a, b) {
        return b - a;
    });

    print(arr[k - 1]);

}

main();


You are given a tree consisting of $$$n$$$ nodes. You want to write some labels on the tree's edges such that the following conditions hold:  Every label is an integer between $$$0$$$ and $$$n-2$$$ inclusive.  All the written labels are distinct.  The largest value among $$$MEX(u,v)$$$ over all pairs of nodes $$$(u,v)$$$ is as small as possible. Here, $$$MEX(u,v)$$$ denotes the smallest non-negative integer that isn't written on any edge on the unique simple path from node $$$u$$$ to node $$$v$$$.

The first line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of nodes in the tree. Each of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) that mean there's an edge between nodes $$$u$$$ and $$$v$$$. It's guaranteed that the given graph is a tree.

Output $$$n-1$$$ integers. The $$$i^{th}$$$ of them will be the number written on the $$$i^{th}$$$ edge (in the input order).

process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  const n = readInt()
  let tree = {}
  for(let i = 0; i < n - 1; i++) {
    const [u, v] = readInts()
    if(!tree[u]) tree[u] = [[v, i]]
    else tree[u].push([v, i])
    if(!tree[v]) tree[v] = [[u, i]]
    else tree[v].push([u, i])
  }
  let ans = new Array(n - 1).fill(-1)
  let c = 0

  // console.log(tree)

  for(let k in tree) {
    if(tree[k].length === 1) {
      if(ans[tree[k][0][1]] === -1) ans[tree[k][0][1]] = c++
    }
  }

  // console.log(ans)
  for(let k in tree) {
    let x = tree[k]
    for(let i = 0, len = x.length; i < len; i++) {
      let el = x[i]
      if(ans[el[1]] === -1) ans[el[1]] = c++
    }
  }
  // console.log(ans)
  wr(ans.join('\n'))
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  const n = getInt()
  const inc = new Array(n + 1).fill(0)
  const G = []
  const ans = {}
  const out = []
  for (let i = 1; i < n; ++i) {
    const ab = getInts()
    const a = ab[0]
    const b = ab[1]
    out.push(make_pair(a, b))

    inc[a] ++
    inc[b] ++
    if (!G[a]) G[a] = []
    if (!G[b]) G[b] = []

    G[a].push(b)
    G[b].push(a)
    ans[make_pair(a, b)] = -1
  }

  let node = -1
  let mx = 0
  for (let i = 1; i <= n; ++i) {
    if (inc[i] > mx) {
      mx = inc[i]
      node = i
    }
  }

  let cnt = 0
  for (let i = 0; i < G[node].length; ++i) {
    const other = G[node][i]
    ans[make_pair(node, other)] = cnt ++
  }

  for (let i in ans) {
    if (ans[i] === -1) ans[i] = cnt ++
  }

  for (let i in out) {
    print(ans[out[i]])
  }
}

function make_pair (a, b) {
  const arr = [a, b]
  arr.sort()
  return arr[0] + '-' + arr[1]
}

process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  const n = readInt()
  let tree = {}
  for(let i = 0; i < n - 1; i++) {
    const [u, v] = readInts()
    if(!tree[u]) tree[u] = [[v, i]]
    else tree[u].push([v, i])
    if(!tree[v]) tree[v] = [[u, i]]
    else tree[v].push([u, i])
  }
  let ans = new Array(n - 1).fill(-1)
  let c = 0

  // console.log(tree)

  for(let k in tree) {
    if(tree[k].length === 1) {
      ans[tree[k][0][1]] = c++
    }
  }
  for(let k in tree) {
    let x = tree[k]
    for(let i = 0, len = x.length; i < len; i++) {
      let el = x[i]
      if(ans[el[1]] === -1) ans[el[1]] = c++
    }
  }
  // console.log(ans)
  wr(ans.join('\n'))
}


Ori and Sein have overcome many difficult challenges. They finally lit the Shrouded Lantern and found Gumon Seal, the key to the Forlorn Ruins. When they tried to open the door to the ruins... nothing happened.Ori was very surprised, but Sein gave the explanation quickly: clever Gumon decided to make an additional defence for the door.There are $$$n$$$ lamps with Spirit Tree's light. Sein knows the time of turning on and off for the $$$i$$$-th lamp — $$$l_i$$$ and $$$r_i$$$ respectively. To open the door you have to choose $$$k$$$ lamps in such a way that there will be a moment of time when they all will be turned on.While Sein decides which of the $$$k$$$ lamps to pick, Ori is interested: how many ways there are to pick such $$$k$$$ lamps that the door will open? It may happen that Sein may be wrong and there are no such $$$k$$$ lamps. The answer might be large, so print it modulo $$$998\,244\,353$$$.

First line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 3 \cdot 10^5$$$, $$$1 \le k \le n$$$) — total number of lamps and the number of lamps that must be turned on simultaneously. Next $$$n$$$ lines contain two integers $$$l_i$$$ ans $$$r_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$) — period of time when $$$i$$$-th lamp is turned on.

Print one integer — the answer to the task modulo $$$998\,244\,353$$$.

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, fn) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = fn(i)) != null) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = fn(i)) != null) return res;
    }
  }
}

function Arr(a, b, fn, init) {
  if (a < b) {
    let arr = Array(b + 1);
    if (init) init(arr);
    for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
    return arr;
  } else {
    let arr = Array(a + 1);
    if (init) init(arr);
    for (let i = a; i >= b; i--) arr[i] = fn(i, arr);
    return arr;
  }
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
let MOD = 998244353;
(async () => {
  // let time = Date.now();
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let n = inp[r++], k = inp[r++];
  let lamp = Arr(0, n - 1, i => ({ l: inp[r++], r: inp[r++] }));
  let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % 998244353n);
  let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : 998244353n - 998244353n / BigInt(i) * a[998244353 % i] % 998244353n);
  for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % 998244353n;
  let nCk = (n, k) => {
    return gt[n] * rgt[k] * rgt[n - k] % 998244353n;
  }
  lamp.sort((l1, l2) => l1.r - l2.r);
  // console.log(lamp);
  let dm = {};
  let dd = 1;
  let s = Array(n + n + 1).fill(0);
  inp.slice(r - n - n, r).sort((a, b) => a - b).forEach(v => {
    if (dm[v]) return;
    dm[v] = dd++;
  });
  lamp.forEach(l => {
    for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++;
  })
  // console.log(dm);
  // console.log(s);
  // let t = new SplayTree();
  // lamp.forEach(l => t.insert(l.l));
  // t.print();
  let res = 0;
  For(0, n - 1, j => {
    // let x = t.count(lamp[i].r, t.root);
    // console.log(i, lamp[i].r, x);
    let x = 0;
    for (let i = dm[lamp[j].r]; i; i -= i & -i) x += s[i];
    // console.log(j, lamp[j].r, dm[lamp[j].l], x);
    if (x >= k) {
      res = (res + parseInt(nCk(x - 1, k - 1))) % 998244353;
    }
    // console.log(res);
    // t.remove(lamp[i].l)
    for (let i = dm[lamp[j].l]; i <= n + n; i += i & -i) s[i]--;
  });
  console.log(res);
  // console.log(Date.now() - time)
})();

class Node {
  left; right; key; size;
  constructor(key) {
    this.key = key;
    this.size = 1;
  }
  update() {
    this.size = 1 + (this.left ? this.left.size : 0) + (this.right ? this.right.size : 0);
  }
  // toString() {
  //   return (this.left ? this.left.toString() + ' ' : '') + `${this.key}` + (this.right ? ' ' + this.right.toString() : '')
  // }
}

class SplayTree {
  root;
  constructor(node) {
    this.root = node;
  }

  uptree(x, p, g) {
    if (!g) {
      // lazy update p, x
      if (p.left == x) {
        p.left = x.right;
        x.right = p;
      } else {
        p.right = x.left;
        x.left = p;
      }
      p.update(); x.update();
      return x;
    }
    // lazy update g, p, x
    if (g.left == p && p.left == x) {
      g.left = p.right;
      p.right = g;
      p.left = x.right;
      x.right = p;
    } else if (g.right == p && p.right == x) {
      g.right = p.left;
      p.left = g;
      p.right = x.left;
      x.left = p;
    } else if (g.left == p) {
      p.right = x.left;
      x.left = p;
      g.left = x.right;
      x.right = g;
    } else {
      p.left = x.right;
      x.right = p;
      g.right = x.left;
      x.left = g;
    }
    g.update(); p.update(); x.update();
    return x;
  }

  splay(trace) {
    var x = trace.pop();
    while (true) {
      var p = trace.pop();
      var g = trace.pop();
      if (!p) return this.root = x;
      if (!g || !trace.length) return this.root = this.uptree(x, p, g);
      if (trace[trace.length - 1].left == g) trace[trace.length - 1].left = x = this.uptree(x, p, g);
      else trace[trace.length - 1].right = x = this.uptree(x, p, g);
    }
  }

  insert(key) {
    if (!this.root) return this.root = new Node(key);
    var trace = [];
    var cur = this.root;
    while (cur) {
      trace.push(cur);
      cur = key < cur.key ? cur.left : cur.right;
    }
    cur = trace[trace.length - 1];
    if (key < cur.key) trace.push[cur.left = new Node(key)];
    else trace.push[cur.right = new Node(key)];
    cur.update();
    this.splay(trace);
  }

  join(tree) {
    if (!this.root) return this.root = tree.root;
    var trace = [this.root];
    var cur = this.root;
    while (cur.right) trace.push(cur = cur.right);
    this.splay(trace);
    this.root.right = tree.root;
    this.root.update();
  }

  remove(key, remove = true) {
    if (!this.root) return;
    var trace = [];
    var cur = this.root;
    while (cur) {
      trace.push(cur);
      if (cur.key == key) break;
      cur = key < cur.key ? cur.left : cur.right;
    }
    if (trace[trace.length - 1].key != key) return;
    this.splay(trace);
    if (!remove) return;
    var tree = new SplayTree(this.root.right);
    this.root = this.root.left;
    this.join(tree);
  }

  count(key) {
    if (!this.root) return 0;
    var cur = this.root;
    var res = 0;
    while (cur) {
      if (key < cur.key) cur = cur.left;
      else {
        res += 1 + (cur.left ? cur.left.size : 0);
        cur = cur.right;
      }
    }
    return res;
  }

  print() {
    console.log(this.root ? this.root.toString() : undefined);
  }
}


Omkar is playing his favorite pixelated video game, Bed Wars! In Bed Wars, there are $$$n$$$ players arranged in a circle, so that for all $$$j$$$ such that $$$2 \leq j \leq n$$$, player $$$j - 1$$$ is to the left of the player $$$j$$$, and player $$$j$$$ is to the right of player $$$j - 1$$$. Additionally, player $$$n$$$ is to the left of player $$$1$$$, and player $$$1$$$ is to the right of player $$$n$$$.Currently, each player is attacking either the player to their left or the player to their right. This means that each player is currently being attacked by either $$$0$$$, $$$1$$$, or $$$2$$$ other players. A key element of Bed Wars strategy is that if a player is being attacked by exactly $$$1$$$ other player, then they should logically attack that player in response. If instead a player is being attacked by $$$0$$$ or $$$2$$$ other players, then Bed Wars strategy says that the player can logically attack either of the adjacent players.Unfortunately, it might be that some players in this game are not following Bed Wars strategy correctly. Omkar is aware of whom each player is currently attacking, and he can talk to any amount of the $$$n$$$ players in the game to make them instead attack another player  — i. e. if they are currently attacking the player to their left, Omkar can convince them to instead attack the player to their right; if they are currently attacking the player to their right, Omkar can convince them to instead attack the player to their left. Omkar would like all players to be acting logically. Calculate the minimum amount of players that Omkar needs to talk to so that after all players he talked to (if any) have changed which player they are attacking, all players are acting logically according to Bed Wars strategy.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The descriptions of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$3 \leq n \leq 2 \cdot 10^5$$$)  — the amount of players (and therefore beds) in this game of Bed Wars. The second line of each test case contains a string $$$s$$$ of length $$$n$$$. The $$$j$$$-th character of $$$s$$$ is equal to L if the $$$j$$$-th player is attacking the player to their left, and R if the $$$j$$$-th player is attacking the player to their right. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, output one integer: the minimum number of players Omkar needs to talk to to make it so that all players are acting logically according to Bed Wars strategy. It can be proven that it is always possible for Omkar to achieve this under the given constraints.

5
4
RLRL
6
LRRRRL
8
RLLRRRLL
12
LLLLRRLRRRLL
5
RRRRR

NoteIn the first test case, players $$$1$$$ and $$$2$$$ are attacking each other, and players $$$3$$$ and $$$4$$$ are attacking each other. Each player is being attacked by exactly $$$1$$$ other player, and each player is attacking the player that is attacking them, so all players are already being logical according to Bed Wars strategy and Omkar does not need to talk to any of them, making the answer $$$0$$$.In the second test case, not every player acts logically: for example, player $$$3$$$ is attacked only by player $$$2$$$, but doesn't attack him in response. Omkar can talk to player $$$3$$$ to convert the attack arrangement to LRLRRL, in which you can see that all players are being logical according to Bed Wars strategy, making the answer $$$1$$$.

var readline=require('readline');
const { Console } = require('console');
var rl=readline.createInterface({
    input:process.stdin,
    output:process.stdout
});
var arr=[];
rl.on('line',function(inp){
    arr.push(inp);
    var len=arr.length;
    if(len%2===1&&len>1){
        var n=parseInt(arr[len-2]),s=arr[len-1],k=-1;
        s+=s;
        for(var i=0;i<n;i++){
            if(s[i]!=s[i+n-1]){
                k=i;
                break;
            }
        }
        if(k===-1) console.log(Math.floor(n/3)+(n%3>0));
        else{
            var pos=k,ans=1,sum=0;
            while(pos<k+n){
                if(s[pos]===s[pos+1]) ans++;
                else{
                    sum+=Math.floor(ans/3);
                    ans=1;
                }
                pos++;
            }
            sum+=Math.floor(ans/3);
            console.log(sum);
        }
    }
    if(len===parseInt(arr[0])*2+1) process.exit(0);
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
  const t = Number(readLine())
  for (let _ = 0; _ < t; _++) {
	const n = Number(readLine())
    let as = readLine()
    let allSame = true
    for (let i = 1; i < n; i++) {
      if (as[i] !== as[0]) {
        as = as.substr(i) + as.substr(0, i)
        allSame = false
        break
      }
    }
    let result = 0
    if (allSame) {
      as = (as[0] === 'L' ? 'R' : 'L') + as.substr(1)
      result = 1
    }
    let currentChar = as[0]
    let currentLength = 1
    for (let i = 1; i < n; i++) {
      if (as[i] !== currentChar) {
        result += (currentLength - (currentLength % 3)) / 3
        currentChar = as[i]
        currentLength = 1
      } else {
        currentLength++
      }
    }
    result += (currentLength - (currentLength % 3)) / 3
    console.log(result)
  }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
  const t = Number(readLine())
  for (let _ = 0; _ < t; _++) {
	const n = Number(readLine())
    let as = readLine()
    for (let i = 1; i < n; i++) {
      if (as[i] !== as[0]) {
        as = as.substr(i) + as.substr(0, i)
        break
      }
    }
    let result = 0
    let currentChar = as[0]
    let currentLength = 1
    for (let i = 1; i < n; i++) {
      if (as[i] !== currentChar) {
        result += ((currentLength + (currentLength % 2)) / 2) - 1
        currentChar = as[i]
        currentLength = 1
      } else {
        currentLength++
      }
    }
    result += ((currentLength + (currentLength % 2)) / 2) - 1
    console.log(result)
  }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
  const t = Number(readLine())
  for (let _ = 0; _ < t; _++) {
	const n = Number(readLine())
    let as = readLine()
    let allSame = true
    for (let i = 1; i < n; i++) {
      if (as[i] !== as[0]) {
        as = as.substr(i) + as.substr(0, i)
        allSame = false
        break
      }
    }
    let result = 0
    if (allSame) {
      as = (as[0] === 'L' ? 'R' : 'L') + as.substr(1)
      result = 1
    }
    let currentChar = as[0]
    let currentLength = 1
    for (let i = 1; i < n; i++) {
      if (as[i] !== currentChar) {
        result += ((currentLength + (currentLength % 2)) / 2) - 1
        currentChar = as[i]
        currentLength = 1
      } else {
        currentLength++
      }
    }
    result += ((currentLength + (currentLength % 2)) / 2) - 1
    console.log(result)
  }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
  const t = Number(readLine())
  for (let _ = 0; _ < t; _++) {
	const n = Number(readLine())
    let as = readLine()
    let allSame = true
    for (let i = 1; i < n; i++) {
      if (as[i] !== as[0]) {
        as = as.substr(i) + as.substr(0, i)
        allSame = false
        break
      }
    }
    if (allSame) {
      console.log(((n - (n % 2)) / 2))
      continue
    }
    let result = 0
    let currentChar = as[0]
    let currentLength = 1
    for (let i = 1; i < n; i++) {
      if (as[i] !== currentChar) {
        result += ((currentLength + (currentLength % 2)) / 2) - 1
        currentChar = as[i]
        currentLength = 1
      } else {
        currentLength++
      }
    }
    result += ((currentLength + (currentLength % 2)) / 2) - 1
    console.log(result)
  }
}


You are a coach of a group consisting of $$$n$$$ students. The $$$i$$$-th student has programming skill $$$a_i$$$. All students have distinct programming skills. You want to divide them into teams in such a way that:  No two students $$$i$$$ and $$$j$$$ such that $$$|a_i - a_j| = 1$$$ belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than $$$1$$$);  the number of teams is the minimum possible. You have to answer $$$q$$$ independent queries.

The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 100$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of students in the query. The second line of the query contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$, all $$$a_i$$$ are distinct), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.

For each query, print the answer on it — the minimum number of teams you can form if no two students $$$i$$$ and $$$j$$$ such that $$$|a_i - a_j| = 1$$$ may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than $$$1$$$)

NoteIn the first query of the example, there are $$$n=4$$$ students with the skills $$$a=[2, 10, 1, 20]$$$. There is only one restriction here: the $$$1$$$-st and the $$$3$$$-th students can't be in the same team (because of $$$|a_1 - a_3|=|2-1|=1$$$). It is possible to divide them into $$$2$$$ teams: for example, students $$$1$$$, $$$2$$$ and $$$4$$$ are in the first team and the student $$$3$$$ in the second team.In the second query of the example, there are $$$n=2$$$ students with the skills $$$a=[3, 6]$$$. It is possible to compose just a single team containing both students.

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    solveWrap(inputString);
});

function solve(arr){
    return arr.sort((a, b) => a-b).some((el, idx, arr) => idx>0&&el==arr[idx-1]+1?true:false)?2:1;
}

function solveWrap(input) {
    let inputAr = input.trim().split('\n');
    let t = inputAr.shift();
    for (let i = 0; i < t; i++) {
        inputAr.shift();
        console.log(solve(inputAr[i].split(' ').map((el) => +el)));
    }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var list = nextIntArray();
    list.sort(function(a,b){
    	return a - b;
    });
    var map = {0:[list[0]]}
    for(var j = 1; j < N; j++){
      var keys = Object.keys(map);
      var isOK = false;
      for(var k = 0; k < keys.length; k++){
        if(map[keys[k]][map[keys[k]].length - 1] + 1 < list[j]){
          isOK = true;
          map[keys[k]].push(list[j]);
          break;
        }
      }
      if(!isOK){
        map[keys.length] = [list[j]];
      }
    }
    var keys = Object.keys(map);
    output[i] = keys.length;
  }
  myout(myconv(output, 9));
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data, n) {
        data.sort((a, b) => a - b);

        let result = 1;
        let index = 0;

        while (index < data.length) {
            if (data[index] + 1 === data[index + 1]) {
                result = 2;
                break;
            }
            index++;
        }
        return result;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let n = lines[testCount * 2 - 1].split(" ").map(Number);

        let result = foo(data, n);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c % 2 === 1) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => a - b);

  let ans = 1;

  for (let i = 1; i < arr.length; i++) {
    if (Math.abs(arr[i - 1] - arr[i]) === 1) {
      ans = 2;
    }
  }

  console.log(ans);
  c++;
});

"use strict";

process.stdin.resume();
process.stdin.setEncoding('utf8');

let input_stdin = '';

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.stdin.on('end', function () {
    let chunks = '';
    chunks = input_stdin.split('\n');
    start(chunks);
});

function start(input) {
    let queries = +input.shift();

    while(queries--) {
        input.shift();
        const array = input.shift().split(' ').map(Number);
        const hash = {};
        let answer = 1;
        for(const element of array) {
            if((element && hash[element - 1]) || hash[element + 1]) {
                answer = 2;
                break;
            }
            hash[element] = true;
        }
        console.log(answer);
    }
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

let countSets = 0;
const dataSets = [];

let step = 0;
let peopleCount;
rl.on('line', (line) => {

  if (!countSets) {
    countSets = Number(line);
    return;
  }

  step++;

  if (!peopleCount) {
    peopleCount = Number(line);
    return;
  }

  let arr = [];
  line.split(' ').map((i) => {
    const n = Number(i);
    arr.push(n);
  });

  function sortNumber(a, b) {
    return a - b;
  }

  arr.sort(sortNumber);
  peopleCount = undefined;
  dataSets.push(arr);

  if (step === countSets * 2) {
    start();
  }
});

function start() {

  for (let i = 0; i < countSets; i++) {
    const groups = [],
          people = dataSets[i];

    for (let item of people) {

      let flag = false;
      for (let a = 0; a < groups.length; a++) {
        if (Math.abs(groups[a] - item) === 1) continue;

        flag = true;
        groups[a] = item;
        break;
      }

      if (!flag) {
        groups.push(item);
      }
    }

    console.log(groups.length);
  }

  rl.close();
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

var gcd = (a, b) => a ? gcd(b % a, a) : b;
var lcm = (a, b) => a * b / gcd(a, b);

function main(){
	let t= +(readLine());
	while(t--){
		let n = +(readLine())
		let a = readLine().split(" ").map(Number);

		a.sort((x,y)=> x-y);
		// console.log(a)
		let f=0;
		for(let i = 0; i <n ;i++){
			if(a[i]+1 == a[i+1]){
				console.log(2);
				f=1;
				break;
			}
		}

		if(!f){
			console.log(1);
		}
	}

}

let data = '';
process.stdin.on('data', c => data += c);

const sol = () =>{
    let ans = [];
    let line = data.trim().split(/\n/g);
    let n = Number(line.shift());
    for(let i = 0; i < n; i++) {
        let num = line[2*i];
        let nums = line[2*i + 1].trim().split(/\s/g).map(Number);
        nums.sort((a, b) => a - b);
        let flag = true;
        for(let j = 0 ; j < num-1; j++){
            if (Math.abs(nums[j] - nums[j+1]) === 1) {
                flag = false;
                break;
            }
        }
        ans.push(flag?1:2);
    }
    console.log(ans.join('\n'));
};

process.stdin.on('end', sol);

t = +readline();
res = '';
while (t-->0){
    n = +readline();
    ar = readline().split(' ').map(Number).sort((a,b)=>a-b);
    teams = [];
    for (i=0;i<n;i++){
        found = false;
        for (j=0;j<teams.length;j++){
            if (teams[j] + 1 !== ar[i]){
                teams[j] = ar[i];
                found = true;
                break;
            }
        }

        if (!found){
            teams.push(ar[i]);
        }
    }
    res += teams.length+'\n';
}
print(res);

 var _tmp = [];
            var _front = 0;
            var readOne = function() {
                if(_front >= _tmp.length) {
                    _tmp = readline().split(' ');
                    _front = 0;
                    return readOne();
                } else {
                    return _tmp[_front++];
                }
            };
            var readInt = function() {
                return parseInt(readOne());
            };
            var readStr = function() {
                return readOne();
            };

            var q = readInt();
            while(q--) {
                var n = readInt();
                var t = [];
                for(var i = 0; i < n; i++) {
                    t[i] = readInt();
                }
                t.sort(function(a, b){return a - b});
                var res = [];
                for(var i = 0; i < n; i++) {
                    for(var j = 0; j < res.length; j++) {
                        if(res[j] + 2 <= t[i]) {
                            res[j] = t[i];
                            break;
                        }
                    }
                    if(j === res.length) {
                        res.push(t[i]);
                    }
                }
                print(res.length);
            }

'use strict';

const nQueues = this.readline().split(" ");

for (let i = 0; i < nQueues; i++) {
  const nStds = this.readline();
  let scoresL = this.readline();

  if(scoresL){
  let scores = [];
  scoresL.split(" ").forEach(el => scores.push(parseInt(el)));

  scores = scores.sort((a, b) => a - b);
  let has = false;
  for (let j = 1; j < nStds; j++) {
    if (Math.abs(scores[j - 1] - scores[j]) === 1) {
      has = true;
      break;
    }
  }
  if (has) {
    this.print(2);
  } else {
    this.print(1);
  }
  }

}

'use strict'
let input = readline()
let i = 1
let flag = true;
let gp = 1
while(i <= input){
    let int = readline()
    let data = readline().split(' ').map(Number);
    let j = 0;
    while(j < data.length){
        let k =j+1
        while(k <data.length){
           if(Math.abs(data[j]-data[k]) == 1 && flag){
                gp++
                flag = false
           }
           k++
        }
        j++
    }
    i++
    print(gp)
    gp = 1
    flag = true
}

'use strict'

const problem = (a) => {
    for (let i = 1; i < a.length; i++) if (a[i] === a[i-1] + 1) return 2;
    return 1;
}

let q = +readline();
while(q--) {
    readline(); print(problem(readline().split(' ').map(Number).sort((a, b) => a - b)));
}

var tc = parseInt(readline());
while(tc--){
    var n = parseInt(readline());
    var arr = readline().split(" ").map(x => parseInt(x));
    var aux = {};
    var dos=false;
    for(var i=0;i<arr.length;i++){
        aux[arr[i]] = i;
        if(aux[arr[i]-1]!==undefined || aux[arr[i]+1]!==undefined)
            dos=true;
    }
    if(dos)
        print(2);
    else
        print(1);
}

q=readline()
while(q-->0){
    n=readline()
    a=readline().split(' ')
    hoga=false
    a.sort(function(a,b){return a-b})
    for(i=0;i<a.length-1;i++){
        if(Math.abs(a[i]-a[i+1])==1)
            hoga=true;
    }
    if(hoga)
        print(2)
    else
        print(1)
}

//var input = readline()
var Test = parseInt(readline());
while(Test -- > 0) {
    var n = parseInt(readline());
    var ar = readline().split(' ').map(x => parseInt(x));
    ar.sort((a, b) => (a - b));
    var check = false;
    for(var i=0; i<n; i++){
        if(ar[i]+1 === ar[i+1]) {
            //print(ar[i]+1 +' '+ ar[i+1]);
            check = true; break;
        }
    }
    print(check ? 2 : 1);
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var list = nextIntArray();
    var count = 0;
    list.sort(function(a,b){
    	return a - b;
    });
    while(list.length > 1){
      var L = list.shift();
      var R = list.pop();
      if(Math.abs(L - R) != 0){
        count++;
      }
    }
    if(count > 0){
      output[i] = count;
    }else if(N == 1){
      output[i] = 1;
    }else{
      output[i] = 0;
    }
  }
  myout(myconv(output, 9));
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var list = nextIntArray();
    var count = 0;
    list.sort(function(a,b){
    	return a - b;
    });
    while(list.length > 1){
      var L = list.shift();
      var R = list.pop();
      if(Math.abs(L - R) != 0){
        count++;
      }
    }
    if(count > 0){
      output[i] = count;
    }else{
      output[i] = 1;
    }
  }
  myout(myconv(output, 9));
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var list = nextIntArray();
    var count = 0;
    list.sort(function(a,b){
    	return a - b;
    });
    while(list.length > 1){
      var L = list.shift();
      var R = list.pop();
      if(Math.abs(L - R) != 1){
        count++;
      }
    }
    if(count > 0){
      output[i] = count;
    }else if(N == 1){
      output[i] = 1;
    }else{
      output[i] = 0;
    }
  }
  myout(myconv(output, 9));
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data, n) {
        data.sort((a, b) => a - b);

        let result = 0;
        let index = 0;

        while (index < data.length) {
            if (data[index] + 1 === data[index + 1]) {
                result++;
                index++;
            }
            index++;
        }
        return result ? result : 1;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let n = lines[testCount * 2 - 1].split(" ").map(Number);

        let result = foo(data, n);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data, n) {
        data.sort((a, b) => a - b);

        let result = 1;
        let index = 0;

        while (index < data.length) {
            if (data[index] + 1 === data[index + 1]) {
                result = 2;
            }
            index++;
            break;
        }
        return result;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let n = lines[testCount * 2 - 1].split(" ").map(Number);

        let result = foo(data, n);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c % 2 === 1) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);

  console.log(Math.max(1, Math.floor(arr.length / 2)));

  c++;
});

"use strict";

process.stdin.resume();
process.stdin.setEncoding('utf8');

let input_stdin = '';

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.stdin.on('end', function () {
    let chunks = '';
    chunks = input_stdin.split('\n');
    start(chunks);
});

function start(input) {
    let queries = +input.shift();

    while(queries--) {
        input.shift();
        const array = input.shift().split(' ').map(Number);
        const hash = {};
        let answer = 1;
        for(const element of array) {
            if((element && hash[element - 1]) || hash[element + 1]) {
                answer = 2;
                break;
            }
        }
        console.log(answer);
    }
}

'use strict';

const nQueues = this.readline().split(" ");

for (let i = 0; i < nQueues; i++) {
  const nStds = this.readline();
  let scoresL = this.readline();
  this.print(scoresL)
  if(scoresL){
  let scores = [];
  scoresL.split(" ").forEach(el => scores.push(parseInt(el)));

  scores = scores.sort((a, b) => a - b);
  let has = false;
  for (let j = 1; j < nStds; j++) {
    if (Math.abs(scores[j - 1] - scores[j]) === 1) {
      has = true;
      break;
    }
  }
  if (has) {
    this.print(2);
  } else {
    this.print(1);
  }
  }

}

var tc = parseInt(readline());
while(tc--){
    var n = parseInt(readline());
    var arr = readline().split(" ").map(x => parseInt(x));
    var aux = [{}];
    //arr.forEach(x => write(x+" "));
    for(var i=0;i<arr.length;i++){
        var cabe=false;
        //print("n = "+arr[i]);
        aux.forEach(function(element){
            if(element[arr[i]+1]===undefined && element[arr[i]-1]===undefined && !cabe) {
                cabe=true;
                element[arr[i]]=i;
            }
        });
        if(!cabe){
            aux.push([]);
            aux[aux.length-1][arr[i]] = i;
        }
    }
    /*aux.forEach(function(element){
        Object.keys(element).forEach(function(key){
            write(key+" ");
        });
        print();
    });*/
    print(aux.length);
}

var tc = parseInt(readline());
while(tc--){
    var n = parseInt(readline());
    var arr = readline().split(" ").map(x => parseInt(x));
    var aux = [{}];
    //arr.forEach(x => write(x+" "));
    for(var i=0;i<arr.length;i++){
        var cabe=false;
        //print("n = "+arr[i]);
        aux.forEach(function(element){
            if(cabe) return;
            if(element[arr[i]+1]===undefined && element[arr[i]-1]===undefined && !cabe) {
                cabe=true;
                element[arr[i]]=i;
            }
        });
        if(!cabe){
            aux.push([]);
            aux[aux.length-1][arr[i]] = i;
        }
    }
    /*aux.forEach(function(element){
        Object.keys(element).forEach(function(key){
            write(key+" ");
        });
        print();
    });*/
    print(aux.length);
}

q=readline()

while(q-->0){
    n=readline()
    a=readline().split(' ')
    hoga=false
    for(i=0;i<a.length-1;i++){
        if(Math.abs(a[i]-a[i+1])==1)
            hoga=true;
    }
    if(hoga)
        print(2)
    else
        print(1)
}

//var input = readline()
var Test = parseInt(readline());
while(Test -- > 0) {
    var n = parseInt(readline());
    var ar = readline().split(' ').map(x => parseInt(x));
    var s = ar.sort((a, b) => (a - b));
    var check = false;
    if(n > 1) {
        if(s[1]-s[0] === 1) check = true;
        else check = false;
    }
    else check = false;
    print(check ? 2 : 1);
}