#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;
const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, M;
map<ll, int> cnts;
int main() {
  cin >> N >> M;
  ll res = 0;
  ll sum = 0;
  cnts[0]++;
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    sum += a;
    sum %= M;
    int key = (M - sum) % M;
    if (i > 0 && a % M == 0) {
      res++;
    }
    res += cnts[key];
    cnts[sum]++;
  }
  cout << res << endl;
  return 0;
}
