#include using namespace std; #include using namespace atcoder; //using mint = static_modint<998244353>; //using mint = modint; using mint = static_modint<1000000007>; using vm = vector; using vvm = vector; ostream &operator<<(ostream &o,const mint &m){cout<; using vvl = vector; using pl = pair; using vp = vector; #define rep(i,n) for(ll i=0;i<(ll)(n);++i) #define reps(i,s,n) for(ll i=(s);i<(ll)(n);++i) #define rep1(i,n) for(ll i=1;i<=(ll)(n);++i) templateinline bool chmax(T &a,T b){return ainline bool chmin(T &a,T b){return a>b?a=b,true:false;} #define fi first #define se second #define pb push_back #define eb emplace_back #define be(v) (v).begin(),(v).end() const long long INF = 1e18; #ifdef DEBUG #include random_device rd; mt19937 gen(rd()); ll random(ll l,ll h){ uniform_int_distribution dist(l,h); return dist(gen); } #endif ll N,X; unordered_map mp; void input(){ cin>>N>>X; rep(n,N){ ll a;cin>>a; mp[a]++; } } #ifdef DEBUG void showall(){ show(N,X,mp); } #endif ll logic(){ ll ans=0; for(auto e:mp){ if(e.fi + e.fi != X){ if(mp.count(X - e.fi)) ans += mp.at(X - e.fi) * e.se; }else if(e.fi + e.fi == X){ ll tmp; if(e.se == 1) tmp = 1; else tmp = e.se * (e.se-1) / 2; ans += tmp; } } return ans; } #ifdef DEBUG ll naive(){ return 1; } #endif int main(){ #ifdef DEBUG cout << "--- Input ---" << endl; #endif input(); #ifdef DEBUG showall(); cout << "--- Logic ---" << endl; #endif ll ans=logic(); #ifdef DEBUG cout << "--- Answer ---" << endl; #endif cout<