#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  long long a = 0;
  map<long long, long long> amari;
  amari[0]++;
  for (int i = 1; N >= i; i++) {
    int tmp;
    cin >> tmp;
    a += tmp;
    amari[a % M]++;
  }
  int kekka = 0;
  for (auto i = amari.begin(); amari.end() != i; i++) {
    kekka += (i->second * (i->second - 1)) / 2;
  }
  cout << kekka << endl;
}
