#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  cin >> n;
  long long m;
  cin >> m;
  long long count = 0, s = 0;
  multiset<long long> ms;
  for (long i = 1; i <= n; i++) {
    long long a;
    cin >> a;
    s = (s + a) % m;
    count += ms.count(s) + (s == 0);
    ms.insert((m - s) % m);
  }
  cout << count << endl;
}
