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