#include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; #define rep(i, j, n) for(int i = j; i < (int)n; ++i) constexpr ll INF = 1LL << 60; constexpr double PI = 3.1415926535897932384626; using namespace std; using C = complex; vector dft(vector& f, int n, int sgn = 1) { if (n == 1) return f; vector f0(n / 2), f1(n / 2); for (int i = 0; i < n / 2; ++i) { f0[i] = f[i * 2 + 0]; f1[i] = f[i * 2 + 1]; } f0 = dft(f0, n / 2, sgn); f1 = dft(f1, n / 2, sgn); C zeta(cos(PI * 2 / n), sin(PI * 2 / n) * sgn); C pow_zeta = 1; for (int i = 0; i < n; ++i) { f[i] = f0[i % (n / 2)] + pow_zeta * f1[i % (n / 2)]; pow_zeta *= zeta; } return f; } vector multiply(vector& g, vector& h) { int n_ = (int)g.size() + (int)h.size() + 1; int n = 1; while (n < n_) n *= 2; g.resize(n); h.resize(n); g = dft(g, n); h = dft(h, n); vector f(n); for (int i = 0; i < n; ++i) f[i] = g[i] * h[i]; // inverse f = dft(f, n, -1); for (int i = 0; i < n; ++i) f[i] /= n; return f; } int main() { cin.tie(0); ios_base::sync_with_stdio(0); ll n, x, t; cin >> n >> x; if (x > 200000) { cout << 0 << endl; return 0; } vector a(100001), b(100001); rep(i, 1, n + 1) { cin >> t; a[t] += 1; b[t] += 1; } vector c = multiply(a, b); cout << (ll)(c[x].real() + 0.5) << endl; return 0; }