#include <bits/stdc++.h>
using namespace std;
const long long inf = 1ll << 62;
const long long mod = 1e9 + 7;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n + 1);
  for (long long i = 0, i_cond = (n); i < i_cond; ++i) {
    cin >> a[i + 1];
    a[i + 1] += a[i];
    a[i + 1] %= m;
  }
  vector<long long> c(m);
  long long ans = 0;
  for (long long i = 0, i_cond = (n + 1); i < i_cond; ++i) {
    ans += c[a[i]];
    c[a[i]]++;
    ;
  }
  cout << ans << endl;
}
