#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int N, zero_num = 0;
  long long M, A, a = 0;
  vector<long long> vec, v;
  cin >> N >> M;
  for (int i = 1; i < N + 1; i++) {
    cin >> A;
    a = (A + a) % M;
    if (a == 0) zero_num++;
    vec.push_back(a);
  }
  int num = 0;
  long long ans = 0;
  while (!vec.empty()) {
    A = vec.back();
    vec.pop_back();
    num = 1;
    while (!vec.empty()) {
      if (vec.back() == A) {
        num++;
        vec.pop_back();
      } else {
        v.push_back(vec.back());
        vec.pop_back();
      }
    }
    ans += (num * (num - 1)) / 2;
    vec = v;
    v.clear();
  }
  cout << ans + zero_num << endl;
  return 0;
}
