#include <bits/stdc++.h>
using namespace std;
template <class T>
void cout_vec(const vector<T> &vec) {
  for (auto itr : vec) cout << itr << ' ';
  cout << endl;
}
const long long mod = 1e9 + 7;
const long long inf = 1e15;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  vector<long long> sum(n + 1, 0);
  map<int, int> cnt;
  cnt[0]++;
  for (long long i = 1; i < n + 1; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
    cnt[sum[i] % m]++;
  }
  long long ans = 0;
  for (auto itr : cnt) {
    ans += (itr.second) * (itr.second - 1) / 2;
  }
  cout << ans << endl;
}
