#include <bits/stdc++.h>
using namespace std;
map<int, int> a;
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  int s = 0, x;
  a[s] = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    s = (s + x) % m;
    a[s]++;
  }
  long long int res = 0;
  for (auto it : a) {
    long long int y = it.second;
    res += y * (y - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
