#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long M;
  cin >> N >> M;
  long long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  map<int, int> mp;
  long long sum[N + 1];
  sum[0] = 0LL;
  mp[0]++;
  for (int i = 1; i <= N; i++) {
    sum[i] = sum[i - 1] + A[i - 1];
    sum[i] = sum[i] % M;
    mp[sum[i]]++;
  }
  long long cnt = 0LL;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second >= 2) {
      int tmp = it->second;
      cnt += tmp * (tmp - 1) / 2;
    }
  }
  cout << cnt << endl;
  return 0;
}
