package com.thinker.bishi.toutiao;

import java.util.Scanner;

/**
 * @author lzh
 */
public class Main1 {

    private static int[] changeToArray(String[] strArray, int len) {
        int[] arr = new int[len];
        for (int i = 0; i < len; i++) {
            arr[i] = Integer.parseInt(strArray[i]);
        }
        return arr;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int len = Integer.parseInt(in.nextLine());
        String[] strArr = in.nextLine().split(" ");
        int[] arr = changeToArray(strArr,len);
        int count = 0;
        for(int i=0;i<len;i++){
            for(int j=i+1;j<len;j++){
                if(Math.abs((arr[i] - arr[j])) <= 10){count ++;}
            }
        }
        System.out.println(count);
    }
}
