#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
map<long long, int> mp;
vector<int> q;
int n;
long long m;
long long a[N];
int main() {
  scanf("%d%lld", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] = a[i] + a[i - 1];
  }
  for (int i = 1; i <= n; i++) a[i] %= m;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!mp[a[i]]) q.push_back(a[i]);
    mp[a[i]]++;
  }
  mp[0]++;
  for (int i = 0; i < q.size(); i++) {
    int num = q[i];
    ans += (mp[num] * (mp[num] - 1)) / 2;
  }
  printf("%lld", ans);
}
