#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
const long long INF = 1LL << 60;
using vll = vector<long long>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pair<long long, long long> = pair<long long, long long>;
using vc = vector<char>;
using vvc = vector<vc>;
long long dx[4] = {0, 1, 0, -1};
long long dy[4] = {1, 0, -1, 0};
int main() {
  long long n, m;
  cin >> n >> m;
  vll a(n);
  for (long long i = 0; i < (n); i++) cin >> a[i];
  vll b(n + 1);
  for (int i = 1; i < n + 1; i++) {
    b[i] = b[i - 1] + a[i - 1];
  }
  vll p(m);
  for (long long i = 0; i < (n + 1); i++) {
    p[b[i] % m]++;
  }
  long long ans = 0;
  for (long long i = 0; i < (m); i++) {
    ans += p[i] * (p[i] - 1) / 2;
  }
  cout << (ans) << endl;
}
