#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
const long long MAX = (1LL << 61);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long a[n], p[n + 1];
  for (int i = 0; i < n; i++) cin >> a[i];
  p[0] = 0;
  for (int i = 0; i < n; i++) p[i + 1] = p[i] + a[i];
  map<long long, int> rems;
  for (int i = 0; i <= n; i++) rems[p[i] % m]++;
  long long tot = 0;
  for (pair<long long, int> x : rems) tot += (x.second * (x.second - 1)) / 2;
  cout << tot << endl;
  return 0;
}
