#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const int mx = 100010;
const long long mod = 1e9 + 7;
int main() {
  long long n, m;
  vector<long long> a(mx);
  vector<long long> b(mx, 0);
  cin >> n >> m;
  for (int i = (int)(0); i < (int)(n); ++i) {
    cin >> a[i];
  }
  unordered_map<long long, int> mp;
  for (int i = (int)(0); i < (int)(n); ++i) {
    b[i + 1] = (b[i] + a[i]) % m;
    mp[b[i + 1]]++;
  }
  mp[0]++;
  long long ans = 0;
  for (auto c : mp) {
    ans += c.second * (c.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
