#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  long long s = 0;
  long long res = 0;
  map<long long, long long> M;
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    s = (s + x) % m;
    res += M[s];
    M[s]++;
  }
  cout << res << endl;
}
