#include using namespace std; typedef long long ll; typedef pair pii; typedef pair pll; #define X first #define Y second #define SZ(a) ((int)a.size()) #define ALL(v) v.begin(), v.end() #define pb push_back int arr[300005]; int main() { ios::sync_with_stdio(0), cin.tie(0); set vis; int n, m; ll ans = 0; cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> arr[i], arr[i] %= m, vis.insert(arr[i]); if (m & 1) return cout << "0\n", 0; for (int i = 1; i <= n; ++i) { int tar = (m / 2 + arr[i]) % m; if (tar > arr[i] && vis.find(tar) != vis.end()) ans += n - 2; } cout << ans << "\n"; }