#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N, M;
  cin >> N >> M;
  vi A(N);
  for (int i = 0; i < (int)(N); ++i) cin >> A[i];
  vi sum(N);
  sum[0] = A[0] % M;
  for (int i = 0; i < (int)(N - 1); ++i) sum[i + 1] = (sum[i] + A[i + 1]) % M;
  map<int, int> G;
  ++G[0];
  for (int i = 0; i < (int)(N); ++i) ++G[sum[i]];
  ll ans = 0;
  for (auto p : G) {
    int &v = p.second;
    ans += v * (v - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
