#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<long long> s(n + 1, 0);
  for (int i = 0; i < n; ++i) {
    s[i + 1] = s[i] + a[i];
  }
  map<int, int> mp;
  for (int i = 0; i <= n; ++i) {
    mp[s[i] % m]++;
  }
  long long ans = 0;
  for (auto a : mp) {
    ans += a.second * (a.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
