#include <bits/stdc++.h>
using namespace std;
int ceil(int a, int b) { return (a + b - 1) / b; }
int round(int a, int b) { return (a + b / 2) / b; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
template <class T>
bool amax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool amin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  const int MAX_N = 100000;
  long long N, M, A[MAX_N + 1] = {};
  map<long long, long long> mp;
  cin >> N >> M;
  for (int i = (int)(1); i < (int)(N + 1); i += (int)(1)) {
    cin >> A[i];
    A[i] += A[i - 1];
    mp[A[i] % M]++;
  }
  long long res = mp[0];
  for (auto it = mp.begin(); it != mp.end(); it++) {
    int n = it->second;
    if (n >= 2) {
      res += n * (n - 1) / 2;
    }
  }
  cout << res << endl;
  return 0;
}
