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