#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<long> a(n);
  for (auto &x : a) cin >> x;
  for (size_t i = 0; i < n - 1; i++) a[i + 1] += a[i], a[i + 1] %= m;
  map<int, int> mp;
  for (auto &x : a) mp[x % m] = mp.find(x % m) == mp.end() ? 1 : mp[x % m] + 1;
  mp[0] = mp.find(0) == mp.end() ? 1 : mp[0] + 1;
  long r = 0;
  for (auto &it : mp) r += (it.second - 1) * it.second / 2;
  cout << r << endl;
}
