#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll=long long; ll const mod = 998244353; using mint = atcoder::modint998244353; #define _REP_OVERLOAD(e1,e2,e3,_REP,...) _REP #define _REP_2(i,x) for(ll i = 0; i < ll(x); i++) #define _REP_3(i,x,y) for(ll i = ll(x); i < ll(y); i++) #define rep(...) _REP_OVERLOAD(__VA_ARGS__, _REP_3, _REP_2)(__VA_ARGS__) #define _IREP_OVERLOAD(e1,e2,e3,_IREP,...) _IREP #define _IREP_2(i,x) for(ll i = ll(x); i > -1; i--) #define _IREP_3(i,x,y) for(ll i = ll(x); i > ll(y); i--) #define irep(...) _IREP_OVERLOAD(__VA_ARGS__, _IREP_3, _IREP_2)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define vec vector #define _V1_OVERLOAD(e1,e2,e3,e4,_V1,...) _V1 #define _V1_2(type,name) vec name #define _V1_3(type,name,n) vec name(n) #define _V1_4(type,name,n,val) vec name(n,val) #define v1(...) _V1_OVERLOAD(__VA_ARGS__, _V1_4, _V1_3, _V1_2)(__VA_ARGS__) #define _V2_OVERLOAD(e1,e2,e3,e4,e5,_V2,...) _V2 #define _V2_2(type,name) vec> name #define _V2_3(type,name,h) vec> name(h) #define _V2_4(type,name,h,w) vec> name(h,vec(w)) #define _V2_5(type,name,h,w,val) vec> name(h,vec(w,val)) #define v2(...) _V2_OVERLOAD(__VA_ARGS__, _V2_5, _V2_4, _V2_3, _V2_2)(__VA_ARGS__) // struct Pos{ll y,x; auto operator<=>(const Pos&) const = default;}; // struct dPos{double y,x; auto operator<=>(const dPos&) const = default;}; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } // const vec Dir4={Pos(-1,0),Pos(1,0),Pos(0,-1),Pos(0,1)}; // UDLR // const vec Dir8={Pos(-1,0),Pos(1,0),Pos(0,-1),Pos(0,1),Pos(-1,-1),Pos(1,1),Pos(-1,1),Pos(1,-1)}; bool inRange(int lower, int val, int upper){return lower<=val && val(const item&) const = default;}; ll llinf=ll(1e18)*2+10; double dinf=1e24; int main() { cout << fixed << setprecision(15); ll N,M; cin>>N>>M; v1(ll,A,N); rep(i,N) { cin>>A[i]; A[i]--;} sort(all(A)); unordered_set setA; rep(i,N){ setA.insert(A[i]); } if(M%2){ cout<<0<<'\n'; return 0; } ll half=ll(M/2); ll res=0; for(auto ai:A){ if(ai>=half) break; // if(setA.count(ai+half)&&setA.count(ai+quarter)) res++; // if(setA.count(ai+half)&&setA.count((ai+half+quarter)%M)) res++; if(setA.count(ai+half)) res+=N-2; } cout<