#include <bits/stdc++.h>
using namespace std;
const int N = 2000100;
const int mod = (int)pow(10, 9) + 7;
const long long INF = 1LL << 60;
string yn(bool b) { return (b ? "Yes" : "No"); }
string YN(bool b) { return (b ? "YES" : "NO"); }
long long n, m, ans;
map<long long, long long> mp;
vector<long long> v;
int main() {
  cin >> n >> m;
  long long a, sum = 0;
  for (long long i = (long long)0; i < (long long)n; ++i) {
    cin >> a;
    sum += a;
    if (sum % m == 0) ++ans;
    mp[sum % m]++;
    sum %= m;
    if (mp[sum % m] == 1) v.push_back(sum % m);
  }
  for (long long i = (long long)0; i < (long long)v.size(); ++i) {
    if (mp[v[i]] > 1) ans += mp[v[i]] * mp[v[i]] - 1 / 2;
  }
  cout << ans << endl;
  return 0;
}
