#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, a;
  cin >> N >> M;
  VI A(N + 1, 0);
  for (int i = (1); i < (int)(N + 1); ++i) {
    cin >> a;
    A.at(i) = (A.at(i - 1) + a) % M;
  }
  int ans = 0;
  map<int, int> ct;
  for (int i = 0; i < (int)(N + 1); ++i) {
    if (ct.count(A.at(i))) {
      ans += ct.at(A.at(i));
      ct.at(A.at(i))++;
    } else
      ct[A.at(i)] = 1;
  }
  cout << ans << endl;
  return 0;
}
