#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int n;
int m;
long long a;
map<int, int> mp;
set<int> st;
int main() {
  mp[0] = 1;
  cin >> n >> m;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    sum += a;
    sum %= m;
    st.insert(sum);
    if (mp.find(sum) == mp.end()) {
      mp[sum] = 1;
    } else {
      mp[sum] += 1;
    }
  }
  long long ans = 0;
  for (auto i : st) {
    if (mp.find(i) != mp.end()) {
      if (mp[i] > 1) {
        ans += mp[i] * (mp[i] - 1) / 2;
      }
    }
  }
  cout << ans << endl;
}
