#include <bits/stdc++.h>
#define int long long
using namespace std;

 
signed main() {
int n,m;
cin >> n >> m;
int s = 0;
int res = 0;
map<int, int> M;
M[0] = 1;
for (int i = 0; i < n; ++i) {
  int x;
  cin >> x;
  s = (s + x) % m;
  res += M[s];
  M[s]++;
}

cout << res << endl;
}