#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 2e5 + 10;
int main() {
  map<int, int> mc;
  int n, m;
  cin >> n >> m;
  mc[0] = 1;
  int sum = 0;
  long long ans = 0;
  while (n--) {
    int x;
    cin >> x;
    sum = (sum + x) % m;
    if (mc.count((m - sum) % m)) ans += mc[(m - sum) % m];
    mc[sum]++;
  }
  cout << ans << endl;
  return 0;
}
