For this Question: Given an array a of N integers. Count the number of triplets (i, j, k) such that 0 &le; i &lt j &lt k &lt N
and |a[i] - a[j]| = |a[j] - a[k]|.First line contains N.
Next line contains N space separated integers.

<b>Constraints</b>
1 &le; N &le; 10<sup>3</sup>
1 &le; a[i] &le; 10<sup>9</sup>A single integer denoting the count of required triplets.Input:
5
5 1 4 3 5

Output:
5

Explanation:
(0, 1, 4) => |a[0] - a[1]| = |a[1] - a[4]| => |5-1| = |1-5| = 4
similarly (0, 2, 4), (0, 3, 4). 
(0, 2, 3) => |a[0] - a[2]| = |a[2] - a[3]| => |5-4| = |4-3| = 1
(1, 3, 4) => |a[1] - a[3]| = |a[3] - a[4]| => |1-3| = |3-5| = 2, I have written this Solution Code: import java.io.*;
import java.util.*;



public class Main {
     
    public static void main(String[] args) {
        
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        
        int n=Integer.parseInt(in.next());
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i]=Integer.parseInt(in.next());
        }
        
        long ans=0;
        for(int j=1;j<(n-1);j++){
            HashMap<Integer,Integer> mp = new HashMap<Integer,Integer>();
            
            for(int i=0;i<j;i++){
                int x=Math.abs(a[i] - a[j]);
                mp.put(x , mp.getOrDefault(x,0) + 1);
            }
            for(int k=j+1;k<n;k++){
                int x=Math.abs(a[j] - a[k]);
                ans += mp.getOrDefault(x,0);
            }
        }
        
        out.print(ans);
        out.close();
    }

    
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }
}
, In this Programming Language: Java, Now tell me if this Code is compilable or not?