#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long int INF = 9e14;
struct edge {
  int to, cost;
};
long long int N, M, K, ans = 0;
long long int A[100010], S[100010];
unordered_map<long long int, long long int> Q;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 0; i < signed(N); i++) {
    cin >> A[i];
    S[i] = A[i];
  }
  for (int i = 0; i < signed(N); i++) S[i + 1] += S[i];
  for (int i = 0; i < signed(N); i++) {
    Q[S[i] % M]++;
  }
  for (auto x : Q) {
    {} {} {}
    if (x.second != 1) {
      ans += x.second * (x.second - 1) / 2;
      if (x.first == 0) ans += x.second;
    }
  }
  cout << ans << endl;
  return 0;
}
