#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long M;
  vector<long long> A;
  A.push_back(0);
  long long a_tmp;
  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    cin >> a_tmp;
    A.push_back(a_tmp);
  }
  unordered_map<int, long long> mp;
  long long sum_tmp, r;
  vector<int> SUM(N + 1);
  SUM[0] = 0;
  for (int i = 0; i < N; ++i) {
    SUM[i + 1] = (SUM[i] + A[i]) % M;
  }
  long long counter = 0;
  for (int i = 0; i < SUM.size(); ++i) {
    counter += mp[SUM[i]];
    mp[SUM[i]]++;
  }
  cout << counter << endl;
}
