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