#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000000 + 7;
int main() {
  cout << setprecision(10);
  long long N, M;
  cin >> N >> M;
  vector<long long> v(N);
  map<int, long long> m;
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
    v.at(i) %= M;
    if (i > 0) {
      v.at(i) += v.at(i - 1);
      v.at(i) %= M;
    }
    if (m.count(v.at(i)) == 0) {
      m[v.at(i)] = 1;
    } else {
      m[v.at(i)]++;
    }
  }
  long long ans = 0;
  for (auto x : m) {
    if (x.first == 0) {
      ans += x.second * (x.second - 1) / 2;
      ans += x.second;
    } else {
      if (x.first < M - x.first) {
        if (m.count(M - x.first) == 0) {
          continue;
        } else {
          ans += x.second * m[M - x.first];
        }
      } else {
        ans += x.second * (x.second - 1) / 2;
      }
    }
  }
  cout << ans << endl;
}
