#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long N, M, A, s;
  cin >> N >> M;
  map<long long, long long> mp;
  mp[0] = 1;
  for (int i = 0; i < N; i++) {
    cin >> A;
    s += A;
    s %= M;
    mp[s]++;
  }
  long long ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    long long n = itr->second;
    ans += n * (n - 1) / 2;
  }
  cout << ans << endl;
  return;
}
int main() { solve(); }
