#include <bits/stdc++.h>
using namespace std;
const double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230;
const long long MOD = 1e9 + 7;
const long long INF = 1e14;
long long mpow(long long a, long long b, long long p = MOD) {
  a = a % p;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b = b >> 1;
  }
  return res % p;
}
map<long long, long long> mo;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long s = 0;
  for (long long i = 0; i < n; i++) {
    s += a[i];
    long long o = s % m;
    mo[o]++;
  }
  long long ans = 0;
  for (long long i = 0; i < m; i++) {
    if (mo[i] > 1) {
      ans += (mo[i] * (mo[i] - 1)) / 2;
    }
  }
  ans += mo[0];
  cout << ans;
  return 0;
}
