#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
map<int, int> f;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int sum = 0;
  ll sol = 0;
  f[0] = 1;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    sum += x;
    sum %= m;
    sol += f[(m - sum) % 10];
    f[sum]++;
  }
  cout << sol;
}
