#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int mod;
  cin >> n >> mod;
  map<int, int> dp;
  dp[0] = 1;
  int a = 0;
  int s = 0;
  for (int i(0); i < n; ++i) {
    int b;
    cin >> b;
    a += b;
    a %= mod;
    s += dp[a];
    ++dp[a];
  }
  cout << s << endl;
}
