/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int arr []=  new int[n];
    
    for(int i=0;i<n;i++){
        arr[i] = sc.nextInt();
    }
    int k = sc.nextInt();
    int ans =0;
    HashMap<Integer,Integer> map = new HashMap<>();
    
    map.put(arr[0],1);
    
    for(int i=1;i<n;i++){
        int temp1 = arr[i] + k;
        int temp2 = arr[i] - k;
        
        if(map.containsKey(temp1)){
            ans = ans + map.get(temp1);
        }
        
        if(map.containsKey(temp2)){
            ans = ans + map.get(temp2);
        }
        
        map.put(arr[i],map.getOrDefault(arr[i],0)+1);
    }
    
    
    System.out.println(ans);
	}
}