#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int A[N];
  map<int, int> m;
  m[0]++;
  long long sum = 0;
  for (int i = (int)0; i < (int)N; i++) {
    cin >> A[i];
    sum += A[i];
    m[sum % M]++;
  }
  long long rsl = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    rsl += (it->second * (it->second - 1)) / 2;
  }
  cout << rsl << endl;
}
