@@ -0,0 +1,1076 @@
+//https://www.hackerrank.com/challenges/sherlock-and-pairs%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic class Solution %7B%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        StringBuffer sb = new StringBuffer();%0A        %0A        //INPUT%0A        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0A        for(byte T = Byte.parseByte(br.readLine()); T %3E 0; --T)%7B%0A            int N = Integer.parseInt(br.readLine());%0A            int%5B%5D A = new int%5BN%5D;%0A            N = 0;%0A            for(String Ai : br.readLine().split(%22 %22))%7B%0A                A%5BN++%5D = Integer.parseInt(Ai);%0A            %7D%0A            %0A            //SOLVE%0A            Arrays.sort(A);%0A            %0A            long sum = 0L;%0A            for(int i = 0; i %3C N;)%7B%0A                int j = i;%0A                while(++j %3C N && A%5Bj-1%5D == A%5Bj%5D)%7B%7D%0A                int count = j - i;%0A                sum += count * (count - 1L);%0A                i = j;%0A            %7D%0A            %0A            //OUTPUT%0A            sb.append(sum + %22%5Cn%22);%0A        %7D%0A        System.out.print(sb);%0A    %7D%0A%7D%0A

Create sherlock-and-pairs.java