#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int A[N];
  long B[N];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    B[i] = ((i > 0) ? B[i - 1] : 0) + A[i];
  }
  map<int, int> map;
  map[0]++;
  for (int i = 0; i < N; ++i) {
    B[i] %= M;
    map[B[i]] += 1;
  }
  long ans = 0;
  for (auto entry : map) {
    ans += (entry.second * (entry.second - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
