#include <bits/stdc++.h>
using namespace std;
const int INF = (long long int)(1 << 30) - 1;
const long long int INFl = (long long int)9223372036854775807;
const int MAX = 10000;
const long long int MOD = (long long int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int n, m;
long long int a[100100];
long long int b[100100];
map<int, int> mp;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long int ans = 0;
  b[0] = (a[0] % m);
  mp[b[0]]++;
  for (int i = 1; i < n; i++) {
    b[i] = (b[i - 1] + a[i]) % m;
    mp[b[i]]++;
  }
  if (mp.find(0) != mp.end()) {
    ans += mp[0];
  }
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    ans += (itr->second) * (itr->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
