#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a < b) gcd(b, a);
  if (b == 1) return 1;
  T r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  return (a.first * a.first + a.second * a.second) >
         (b.first * b.first + b.second * b.second);
}
struct UnionFind {
  vector<int> par;
  vector<int> rank;
  UnionFind(int n = 1) { init(n); }
  void init(int n = 1) {
    par.resize(n);
    rank.resize(n);
    for (int i = 0; i < n; ++i) {
      par[i] = i;
      rank[i] = 0;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }
  bool issame(int x, int y) { return root(x) == root(y); }
  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;
    return true;
  }
};
int main(int argc, const char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long int N, M;
  cin >> N >> M;
  long long int S = 0;
  long long int B = 0;
  map<int, int> m;
  m[0] = 1;
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    int A;
    cin >> A;
    B = (B + A) % M;
    m[B]++;
  }
  for (auto it = m.begin(); it != m.end(); it++) {
    if (it->second > 1) {
      S += it->second * (it->second - 1) / 2;
    }
  }
  cout << S << endl;
}
