#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100000;
int S[MaxN + 10];
int main() {
  int i;
  int N;
  int M;
  int A;
  int x;
  long long iCnt;
  long long iSum;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  cin >> M;
  iSum = 0;
  iCnt = 0;
  for (i = 1; i <= N; i++) {
    cin >> A;
    iSum += A;
    iSum %= M;
    S[i] = iSum;
  }
  sort(S, S + (N + 1));
  x = 0;
  for (i = 1; i <= N; i++) {
    if (S[i - 1] == S[i])
      x++;
    else {
      iCnt += (x + 1) * x / 2;
      x = 0;
    }
  }
  if (x > 0) iCnt += (x + 1) * x / 2;
  cout << iCnt << endl;
  return 0;
}
