#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;
const int MOD = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<int> cumsum(n + 1, 0);
  for (int i = 0; i < (n); ++i) {
    cumsum[i + 1] = (cumsum[i] + a[i]) % m;
  }
  map<int, int> mp;
  for (int i = 0; i < (n + 1); ++i) {
    mp[cumsum[i]]++;
  }
  ll ans = 0;
  for (auto itr : mp) {
    ans += itr.second * (itr.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
