@@ -0,0 +1,1544 @@
+//https://www.hackerrank.com/challenges/equal%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            final short N = Short.parseShort(br.readLine());%0A            final short%5B%5D A = new short%5BN%5D;%0A            String%5B%5D input = br.readLine().split(%22 %22);%0A            for(short i = 0; i %3C N; ++i)%7B%0A                A%5Bi%5D = Short.parseShort(input%5Bi%5D);%0A            %7D%0A            input = null;%0A            %0A            //SOLVE%0A            if(N %3C 2)%7B%0A                sb.append(%220%5Cn%22);%0A                continue;%0A            %7D%0A            %0A            int minVal = A%5B0%5D;%0A            for(int i = 1; i %3C N; ++i)%7B%0A                if (A%5Bi%5D %3C minVal)%7B%0A                    minVal = A%5Bi%5D;%0A                %7D%0A            %7D%0A            %0A            int minCount = Integer.MAX_VALUE;%0A            for(int i = 0; i %3C= 5; ++i)%7B%0A                int count = 0;%0A                for(short j = 0; j %3C N; ++j)%7B%0A                    short V = (short)(A%5Bj%5D - (minVal - i));%0A                    count += V/5 + (V %25= 5)/2 + (V & 1);%0A                %7D%0A                if (count %3C minCount)%7B%0A                    minCount = count;%0A                %7D%0A            %7D%0A            %0A            //OUTPUT%0A            sb.append(minCount+ %22%5Cn%22);%0A        %7D%0A        System.out.print(sb);%0A    %7D%0A%7D%0A

Create equal.java