#include <bits/stdc++.h>
void init(int n);
int find(int n);
void unite(int x, int y);
bool same(int x, int y);
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};
using namespace std;
bool cmp_P(const pair<long long int, long long int> &a,
           const pair<long long int, long long int> &b) {
  return a.second < b.second;
}
int main() {
  long long int dsum = 0, N, l = 0, r = 1, A[100001], sum[100001], z[100001],
                M = 0, res = 0, renzoku = 0;
  map<int, int> mp;
  cin >> N >> M;
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  sum[0] = A[0] % M;
  for (int i = 0; i < (int)(N); i++) {
    A[i] %= M;
    sum[i + 1] = (sum[i] + A[i + 1]) % M;
  }
  for (int i = 0; i < (int)(N); i++) {
    res += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << res << endl;
  return 0;
}
int par[100001];
int ranks[100001];
void init(int n) {
  for (int i = 0; i < (int)(n); i++) {
    par[i] = i;
    ranks[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (ranks[x] < ranks[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (ranks[x] == ranks[y]) ranks[x]++;
  }
}
bool same(int x, int y) { return find(x) == find(y); }
