#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (auto &v : a) cin >> v;
  for (int i = 0; i < n-1; i++) a[i+1] += a[i];
  for (int i = 0; i < n; i++) a[i] %= m;
  sort(a.begin(), a.end());
  ll cnt;
  ll sum = 0;
  for (int i = 0; i < n-1; i++) {
    cnt = 1;
    if (a[i] == 0) sum++;
    while (i < n-1 && a[i] == a[i+1]) {
      if (a[i+1] == 0) sum++;
      i++;
      cnt++;
    }
    sum += cnt*(cnt-1)/2;
  }
  dump(sum);
  return 0;
}
