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