#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int a[N];
  int b[N + 1];
  b[0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[N];
    if (i > 0) b[i] = (b[i - 1] + a[i]) % M;
  }
  b[N] = b[N - 1];
  map<int, int> ma;
  int sum = 0;
  for (int i = 0; i < N + 1; i++) {
    sum += ma[b[i]];
    ma[b[i]]++;
  }
  cout << sum;
}
