#include <bits/stdc++.h>
using namespace std;
int N, M, a[101010], A;
unordered_map<int, int> m;
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", a + i);
    a[i] += a[i - 1];
    a[i] %= M;
    A += m[a[i]]++;
  }
  cout << A << endl;
  return 0;
}
