#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;
template <class T>
inline T isPrime(T x) {
  bool ret = true;
  if (x < 2) {
    ret = false;
  }
  for (long long i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) {
      ret = false;
    }
  }
  return ret;
}
struct UnionFind {
  vector<int> par;
  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};
int main(int argc, char const* argv[]) {
  int n, m;
  cin >> n >> m;
  vector<long long> a(n, 0), sum(n, 0);
  map<int, int> mp;
  cin >> a[0];
  sum[0] = a[0];
  mp[sum[0] % m]++;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    sum[i] += sum[i - 1] + a[i];
    mp[sum[i] % m]++;
  }
  long long ans = mp[0];
  for (auto&& var : mp) {
    ans += var.second * (var.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
