#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main(void) {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  long long ans = 0;
  mp[0] = 1;
  int s = 0;
  while (n--) {
    int x;
    cin >> x;
    s = (s + x) % m;
    ans += mp[s];
  }
  cout << ans;
  return 0;
}
