#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class PalseError {};
class Edge {
 public:
  int from, to, value;
  Edge(LL a, LL b, LL c) {
    from = a;
    to = b;
    value = c;
  }
  Edge(LL a, LL b) {
    from = a;
    to = b;
  }
};
LL flag[100010];
int main() {
  int(N);
  cin >> (N);
  int(M);
  cin >> (M);
  vector<int> vec;
  for (int a = 0; a < (N); ++a) {
    int(B);
    cin >> (B);
    vec.push_back(B);
  }
  for (int a = 0; a < (N); ++a) {
    flag[a + 1] = flag[a] + vec.at(a);
  }
  int co = 0;
  map<LL, int> mp;
  for (int a = 0; a <= N; a++) {
    mp[flag[a] % M]++;
  }
  for (auto que : mp) {
    co += que.second * (que.second - 1);
  }
  cout << (co / 2) << endl;
  return 0;
}
