#include <bits/stdc++.h>
using namespace std;
int N, M, v;
map<int, int> num;
int main() {
  cin >> N >> M;
  num[0]++;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &v);
    sum = (sum + v) % M;
    num[sum]++;
  }
  long long ans = 0;
  for (map<int, int>::iterator it = num.begin(); it != num.end(); ++it) {
    int val = it->second;
    ans += val * (val - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
