#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;
long long a[N];
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  map<long long, long long> mp[2];
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int j = 1 - i % 2;
    mp[i % 2].clear();
    for (auto it = mp[j].begin(); it != mp[j].end(); it++) {
      long long f = it->first;
      mp[i % 2][(f + a[i]) % m] += mp[j][f];
    }
    mp[i % 2][a[i] % m]++;
    ans += mp[i % 2][0];
  }
  cout << ans << endl;
}
