#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
inline void rvi(vector<int>& v, int n) {
  int temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    v.push_back(temp);
  }
}
inline void rvll(vector<long long int>& v, int n) {
  long long int temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    v.push_back(temp);
  }
}
inline void prvi(vector<int>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
inline void prvll(vector<long long int>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
inline void prmii(map<int, int>& m) {
  for (auto x : m) {
    cout << x.first << " " << x.second << endl;
  }
}
inline vector<long long int> prefixsum(vector<int>& a) {
  vector<long long int> b;
  b.push_back(a[0]);
  for (int i = 1; i < a.size(); i++) {
    b.push_back(a[i] + b[i - 1]);
  }
  return b;
}
inline vector<long long int> suffixsum(vector<int>& a) {
  vector<long long int> b((a.size()));
  b[(a.size()) - 1] = a[(a.size()) - 1];
  for (int i = (a.size()) - 1 - 1; i >= 0; i--) {
    b[i] = a[i] + b[i + 1];
  }
  return b;
}
inline vector<long long int> prefixsum(vector<long long int>& a) {
  vector<long long int> b;
  b.push_back(a[0]);
  for (int i = 1; i < a.size(); i++) {
    b.push_back(a[i] + b[i - 1]);
  }
  return b;
}
inline vector<long long int> suffixsum(vector<long long int>& a) {
  vector<long long int> b((a.size()));
  b[(a.size()) - 1] = a[(a.size()) - 1];
  for (int i = (a.size()) - 1 - 1; i >= 0; i--) {
    b[i] = a[i] + b[i + 1];
  }
  return b;
}
void solve();
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long int> p = prefixsum(a);
  for (int i = 0; i < n; i++) p[i] = p[i] % m;
  map<int, int> mapi;
  for (int i = 0; i < n; i++) mapi[p[i]]++;
  auto it = mapi.begin();
  long long int count = 0;
  if (it->first == 0) count += it->second;
  for (auto& x : mapi) {
    if (x.second > 1) {
      count += (x.second * (x.second - 1)) / 2;
    }
  }
  cout << count << endl;
}
