#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}
const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 29;
const long long INFL = 1e18;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
void solve(void) {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  map<long long, long long> mp;
  while (N--) {
    int a;
    cin >> a;
    sum += a;
    sum %= M;
    mp[sum]++;
  }
  long long ans = 0;
  for (auto p : mp) {
    ans += p.second * (p.second + 1) / 2;
  }
  cout << ans << endl;
}
int main(void) {
  solve();
  return 0;
}
