#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 2e15;
const double PI = acos(-1);
vector<pair<long long, int>> vectorCnt(vector<long long> a) {
  sort(a.begin(), a.end());
  int n = a.size();
  vector<pair<long long, int>> b;
  int cnt = 1;
  for (int i = 0; i < n - 1; i++) {
    if (a[i + 1] != a[i]) {
      b.push_back(make_pair(a[i], cnt));
      cnt = 1;
    } else {
      ++cnt;
    }
  }
  b.push_back(make_pair(a[n - 1], cnt));
  return b;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = a[i] % m;
  }
  for (int i = 0; i < n - 1; i++) {
    a[i + 1] += a[i];
    a[i + 1] = a[i + 1] % m;
  }
  vector<pair<long long, int>> b = vectorCnt(a);
  long long ans = 0;
  for (int i = 0; i < b.size(); i++) {
    int cnt = b[i].second;
    if (b[i].first == 0) ans += cnt;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
