#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 60) - 1;
const int N = 1e5 + 20;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long m;
  cin >> m;
  long long s = 0;
  int ans = 0;
  map<long long, int> mp;
  mp[0] = 1;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    long long x;
    cin >> x;
    s += x;
    ans += mp[s % m];
    mp[s % m]++;
  }
  cout << ans;
  return 0;
}
