#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100010];
map<int, int> mp;
int main() {
  cin >> n;
  cin >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long s[100010];
  long long sum = 0;
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    s[i + 1] = sum;
  }
  for (int i = 0; i < n + 1; i++) {
    mp[s[i] % m]++;
  }
  long long res = 0;
  for (auto ite = mp.begin(); ite != mp.end(); ite++) {
    int a = ite->second;
    res += a * (a - 1) / 2;
  }
  cout << res << "\n";
  return 0;
}
