#include <bits/stdc++.h>
using namespace std;
long long a[100009], arr[100009];
map<long long, long long> ma;
vector<long long> v[100009];
long long sol(long long n) { return (n * (n + 1)) / 2; }
int main() {
  long long i, n, t, k, j, x = 0, y = 0, m;
  scanf("%lld %lld", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%lld", &x);
    arr[i] = x;
    if (i == 0)
      a[i] = x;
    else
      a[i] = a[i - 1] + x;
    a[i] = a[i] % m;
  }
  long long ind = 0;
  for (i = 0; i < n; i++) {
    if (ma.find(a[i]) == ma.end()) {
      ma[a[i]] = ind++;
    }
    v[ma[a[i]]].push_back(i);
  }
  long long ans = v[0].size();
  x = 0;
  long long hi, lo, mid, temp;
  for (i = 0; i < n; i++) {
    x += arr[i];
    x = x % m;
    lo = 0;
    hi = v[ma[x]].size() - 1;
    temp = -1;
    while (lo <= hi) {
      mid = (lo + hi) / 2;
      if (v[ma[x]][mid] > i) {
        temp = mid;
        hi = mid - 1;
      } else
        lo = mid + 1;
    }
    if (temp != -1) {
      ans += v[ma[x]].size() - temp;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
