#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long array[n];
  vector<long long> v;
  long long sum = 0;
  long long count = 0;
  for (int i = 0; i < n; ++i) {
    cin >> array[i];
    sum += array[i];
    sum %= m;
    if (sum == 0) count++;
    v.push_back(sum);
  }
  long long pairs = 0;
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    int freq = 0;
    i = lower_bound(v.begin(), v.end(), v[i]) - v.begin();
    int temp = upper_bound(v.begin(), v.end(), v[i]) - v.begin();
    freq = temp - i;
    i = upper_bound(v.begin(), v.end(), v[i]) - v.begin();
    i--;
    if (freq > 1) {
      pairs += (freq * (freq - 1)) / 2;
    }
  }
  pairs += count;
  cout << pairs << endl;
  return 0;
}
