#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
i64 N, M;
i64 A[101010];
i64 sum[101010];
int main() {
  cin >> N >> M;
  for (int(i) = (1); (i) <= (N); (i)++) {
    cin >> A[i];
    sum[i] = sum[i - 1] + A[i];
    sum[i] %= M;
  }
  map<i64, int> mp;
  int ans = 0;
  mp[0] = 1;
  for (int(i) = (1); (i) <= (N); (i)++) {
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << ans << endl;
}
