#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long m, n;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= m;
  }
  vector<long long> cumusum(n);
  cumusum[0] = a[0];
  for (int i = 0; i < n - 1; i++) {
    cumusum[i + 1] = a[i + 1] + cumusum[i];
    cumusum[i + 1] %= m;
  }
  int result = 0;
  for (int i = 0; i < n; i++) {
    if (cumusum[i] == 0) {
      result++;
    }
  }
  map<long long, int> nums;
  for (int i = 0; i < n; i++) {
    if (nums.find(cumusum[i]) == nums.end()) {
      nums.insert({cumusum[i], 1});
    } else {
      nums[cumusum[i]]++;
    }
  }
  for (auto itr = nums.begin(); itr != nums.end(); ++itr) {
    result += ((itr->second) * (itr->second - 1)) / 2;
  }
  cout << result << endl;
  return 0;
}
