#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
long long INF = 1e18;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n + 10);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> sum(n + 10, 0);
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i - 1];
  }
  map<long long, int> mod_sum;
  set<long long> s;
  for (int i = 0; i <= n; i++) {
    mod_sum[sum[i] % m]++;
    s.insert(sum[i] % m);
  }
  long long ans = 0;
  for (long long i : s) {
    ans += (mod_sum[i] * (mod_sum[i] - 1)) / 2;
  }
  cout << ans << endl;
}
