#include <bits/stdc++.h>
using namespace std;
int n, m;
int x, sum, ans;
map<int, int> mmp;
int main() {
  scanf("%d%d", &n, &m);
  sum = 0;
  ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    sum += x;
    ans += mmp[sum % m];
    if (sum % m == 0) ans++;
    mmp[sum % m]++;
  }
  printf("%d\n", ans);
  return 0;
}
