#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long int linf = 1LL << 50;
int a[100001];
long long int sum[100001];
map<int, long long int> mp;
int main(int argc, char const* argv[]) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  sum[0] = a[0];
  for (int i = 0; i < n; i++) sum[i] = sum[i - 1] + a[i];
  for (int i = 0; i < n; i++) mp[int(sum[i] % m)]++;
  long long int res = mp[0];
  long long int tmp = sum[0] % m;
  for (int i = 0; i < n - 1; i++) {
    mp[int(sum[i] % m)]--;
    res += mp[tmp % m];
    tmp = sum[i + 1] % m;
  }
  if (a[n - 1] % m == 0) res++;
  cout << res << endl;
  return 0;
}
