#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000000;
const int MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<long long> s(n + 1);
  s[0] = 0;
  for (int i = 0; i < (n); i++) {
    s[i + 1] = s[i] + a[i];
  }
  map<int, int> w;
  for (int i = 0; i < (n); i++) {
    w[s[i + 1] % m]++;
  }
  w[0]++;
  long long ans = 0;
  for (auto p : w) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << (ans) << endl;
  return 0;
}
