#include <bits/stdc++.h>
using namespace std;
int N, M;
map<int, long long> R;
int main() {
  scanf("%d%d", &N, &M);
  int Sum = 0, a;
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a);
    Sum = (Sum + a) % M;
    R[Sum]++;
  }
  long long Ans = 0;
  for (map<int, long long>::iterator it = R.begin(); it != R.end(); it++) {
    if (it->first == 0) Ans += it->second;
    Ans = Ans + it->second * (it->second - 1) / 2;
  }
  printf("%I64d", Ans);
}
