#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long ans = 0;
  long long n, m;
  cin >> n >> m;
  vector<long long> A(n);
  for (long long i = 0; i < n; i++) {
    cin >> A[i];
  }
  vector<long long> B(n + 1);
  B[0] = 0;
  map<long long, long long> C;
  C[0] = 1;
  for (long long i = 0; i < n; i++) {
    B[i + 1] = (B[i] + A[i]) % m;
    C[B[i + 1]]++;
  }
  for (auto m : C) {
    ans += (m.second - 1) * m.second / 2;
  }
  cout << m << endl;
}
