#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,a = readInts()
x = list(map(lambda x:int(x)-a, input().split()))
#print(x)
dic = Counter(x)
#print(dic)
ans = 0
for k,v in dic.copy().items():
    if k == 0:
        ans += 2**v - 1
    else:
        if dic[k] != -1:
            ans += dic[k]*dic[-k]
            ans += dic[k]*dic[-k] * dic[0]
            dic[k] = -1
            dic[-k] = -1
print(ans)
