#include <bits/stdc++.h>
const int MAX = 510000;
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int b[m];
  map<long long, long long> B;
  memset(b, 0, sizeof(b));
  int cur_sum = 0;
  for (int i = 0; i < n; i++) {
    cur_sum += a[i];
    cur_sum %= m;
    B[cur_sum]++;
  }
  long long ans = B[0];
  for (auto i : B) {
    ans += (i.second * (i.second - 1) / 2);
  }
  cout << ans << endl;
}
