#include <bits/stdc++.h>
using namespace std;
long long longinf = 1ll << 60;
int inf = 1 << 29;
long long N, M;
long long A[100002];
long long B[100002];
long long S[100002];
map<int, int> mp;
int main() {
  cin >> N >> M;
  for (int i = (int)1; i < (int)N + 1; i++) {
    cin >> A[i];
  }
  S[0] = 0;
  B[0] = 0;
  for (int i = (int)1; i < (int)N + 1; i++) {
    S[i] = S[i - 1] + A[i];
    B[i] = S[i] % M;
  }
  for (int i = (int)0; i < (int)N + 1; i++) {
    mp[B[i]]++;
  }
  long long ans = 0;
  for (int i = (int)0; i < (int)N + 1; i++) {
    if (mp[B[i]] > 0) {
      ans += (mp[B[i]] * (mp[B[i]] - 1)) / 2;
      mp[B[i]] = 0;
    }
  }
  cout << ans << endl;
}
