#include long long int h[100005], l; int comp_h(long long int a, long long int b) { if (h[a] > h[b]) return 1; else return -1; } void swap_h(long long int a, long long int b) { long long int f = h[a]; h[a] = h[b]; h[b] = f; return; } void push(long long int ne) { h[l] = ne; long long int p = l; l++; for (; p > 0; p = (p - 1) / 2) if (comp_h((p - 1) / 2, p) > 0) swap_h((p - 1) / 2, p); return; } long long int pop() { l--; swap_h(0, l); long long int p = 0; for (;;) { if (2 * p + 2 < l) { if (comp_h(2 * p + 1, 2 * p + 2) > 0) { if (comp_h(p, 2 * p + 2) > 0) swap_h(p, 2 * p + 2); p = 2 * p + 2; } else { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } } else if (2 * p + 1 < l) { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } else break; } return h[l]; } long long int a[100005]; long long int cnt[100005]; int main() { long long int n, m; scanf("%lld %lld", &n, &m); long long int i, j; for (i = 0; i < n; i++) scanf("%lld", &a[i]); if (m == 1) { printf("1\n"); return 0; } for (i = 0; i < n; i++) a[i] %= m; l = 0; for (i = 0; i < n; i++) push(a[i]); for (i = 0; i < n; i++) a[i] = pop(); cnt[0] = 1; for (i = 1; i < n; i++) { if (a[i] == a[i - 1]) cnt[i] = cnt[i - 1] + 1; else cnt[i] = 1; } long long int ans = 0; i = 0; a[n] = -1; if (a[i] == 0) { ans++; while (a[i] == 0) i++; } for (j = n - 1; i <= j;) { while (a[i] == a[i + 1]) i++; if (i > j) break; if (a[i] + a[j] < m) { ans += cnt[i]; i++; } else if (a[i] + a[j] > m) { ans += cnt[j]; while (a[j - 1] == a[j]) j--; j--; } else { if (i == j) { ans++; break; } else { if (cnt[i] > cnt[j]) ans += cnt[i]; else ans += cnt[j]; i++; while (a[j - 1] == a[j]) j--; j--; } } } printf("%lld\n", ans); return 0; }