#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, long long>;
long long factorial(long long k) {
  long long sum = 1;
  for (long long i = 1; i <= k; ++i) {
    sum *= i;
  }
  return sum;
}
void solve_abc105_d() {
  long long N, M;
  cin >> N >> M;
  long long A;
  vector<long long> sum(N + 1, 0);
  multimap<long long, char> ms;
  for (long long i = 0; i < (long long)(N); i++) {
    cin >> A;
    sum[i + 1] = (sum[i] + A) % M;
    if (ms.find(sum[i + 1]) != ms.end()) {
      ms.find(sum[i + 1])->second++;
    } else {
      ms.emplace(sum[i + 1], 1);
    }
  }
  long long ans = 0;
  for (auto itr = ms.begin(); itr != ms.end(); itr++) {
    if (itr->first == 0) {
      ans += (itr->second * (itr->second - 1)) / 2 + itr->second;
    } else if (itr->second > 1) {
      if (itr->second == 2) {
        ans += 1;
      } else {
        ans += (itr->second * (itr->second - 1)) / 2;
      }
    }
  }
  cout << ans << "\n";
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve_abc105_d();
  return 0;
}
