#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 1e5 + 3;
map<int, int> freq;
int v[T];
int n, MOD;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> MOD;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    v[i] = (v[i] + v[i - 1]) % MOD;
    freq[v[i]]++;
  }
  freq[0]++;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    freq[v[i - 1]]--;
    long long x = (v[i] - v[i - 1] + MOD) % MOD;
    ans += (long long)freq[x];
  }
  cout << ans << '\n';
  return 0;
}
