#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return s; }
template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; i++) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}
void debug() { cerr << endl; }
template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}
void print() { cout << endl; }
template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < (int)N; i++) cin >> A[i];
  vector<long long> acc(N + 1);
  map<long long, int> list;
  list[0] = 1;
  for (int i = 0; i < (int)N; i++) {
    acc[i + 1] = (i > 0 ? acc[i] : 0) + A[i];
    list[acc[i + 1] % M]++;
  }
  long long ans = 0;
  for (pair<long long, int> p : list) {
    ans += p.second * (p.second - 1) / 2;
  }
  print(ans);
  return 0;
}
