#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  long long m, b[100001], c = 0;
  unordered_map<int, int> u;
  cin >> n >> m;
  b[0] = 0;
  u[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    b[i] = (b[i] + b[i - 1]) % m;
    u[b[i]]++;
  }
  for (auto x = u.begin(); x != u.end(); x++) {
    int y = x->second;
    c += y * (y - 1) / 2;
  }
  cout << c << endl;
}
