#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
int main() {
  long n, m;
  cin >> n >> m;
  vector<long> sum(n + 1);
  sum.at(0) = 0;
  for (int i = 0; i < (int)(n); i++) {
    long a;
    cin >> a;
    sum.at(i + 1) = sum.at(i) + a;
  }
  map<long, long> mp;
  for (int i = 0; i < (int)(n + 1); i++) {
    long tmp = sum.at(i) % m;
    if (mp.count(tmp))
      mp.at(tmp)++;
    else
      mp[tmp] = 1;
  }
  long ans = 0;
  for (int i = 0; i < (int)(m); i++) {
    if (mp.count(i)) {
      long tmp = mp.at(i) * (mp.at(i) - 1) / 2;
      ans += tmp;
    }
  }
  cout << ans << endl;
}
