#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N, cin >> M;
  int A[N];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  int B[N + 1];
  B[0] = 0;
  set<int> B_set;
  for (int j = 0; j < N; ++j) {
    B[j + 1] = B[j] + A[j];
    B[j + 1] %= M;
    B_set.insert(B[j + 1]);
  }
  map<int, int> mods;
  for (int x : B_set) {
    mods[x] = 0;
  }
  for (int b : B) {
    mods[b]++;
  }
  int ans = 0;
  for (int l : B_set) {
    int r = mods[l];
    if (r == 0) {
      continue;
    }
    ans += (r * (r - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
