#include <bits/stdc++.h>
using namespace std;
const int ms = 1e5 + 9;
long long vet[ms], n, soma[ms], m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> vet[i];
  for (int i = 1; i <= n; i++) soma[i] = (soma[i - 1] + vet[i]) % m;
  for (int i = 0; i <= n; i++) cout << soma[i];
  cout << endl;
  map<long long, long long> mapa;
  long long ans = 0;
  for (int i = 0; i <= n; i++) mapa[soma[i]]++;
  for (auto it : mapa) {
    ans += (it.second * (it.second - 1)) / 2;
  }
  cout << ans;
}
