#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
int prime[] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31, 37, 41,
               43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
const long long inf = 1e9 + 7;
int main() {
  long long n, m;
  cin >> n >> m;
  long long a[n], s[n];
  map<long long, int> nums;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long sum = 0;
  nums[sum]++;
  for (int i = 0; i < n; i++) {
    sum = (sum + a[i]) % m;
    nums[sum]++;
  }
  for (auto itr = nums.begin(); itr != nums.end(); itr++) {
    ans += itr->second * (itr->second - 1) / 2;
  }
  cout << ans << endl;
}
