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