from collections import Counter
def main():
    n, c = map(int, input().split())
    nums = list(map(int, input().split()))

    counts = Counter(nums)

    result = 0
    for val, num_val in counts.items():
        target = val - c
        if target in counts:
            result += num_val * counts[target]

    print(result)


if __name__ == "__main__":
    main()