#include <bits/stdc++.h>
const long long mod = (long long)1e9 + 7;
const long long inf = (long long)1e18;
using namespace std;
const long long N = 1e5 + 5;
long long arr[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  map<long long, long long> mp;
  mp[0] = 1;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
    arr[i] += arr[i - 1];
    ans += mp[arr[i] % m];
    mp[arr[i] % m]++;
  }
  cout << ans << "\n";
  return 0;
}
