#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  unordered_map<int, int> cnt;
  cnt[0]++;
  int prev = 0;
  uint64_t ans = 0;
  for (int i = 0; i < n; ++i) {
    int tmp;
    scanf("%d", &tmp);
    prev = (prev + tmp) % m;
    ans += cnt[prev]++;
  }
  cout << ans << "\n";
}
