#include using namespace std; int main(){ int N, M; cin >> N >> M; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } for (int i = 0; i < N; i++){ A.push_back(A[i] + M); } if (M % 2 == 1){ cout << 0 << endl; return 0; } long long ans = 0; for (int i = 0; i < N; i++){ auto it = lower_bound(A.begin(), A.end(), A[i] + M / 2); if (it != A.end() and *it == A[i] + M / 2){ ans += it - A.begin() - i - 1; } } cout << ans << endl; }