#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
ll const mod = 998244353;
const ll MAX = 300000;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<P>>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> r(m);
  r[0] = 1;
  ll sum = 0, ans = 0;
  for (long long i = 0; i < n; ++i) {
    int a;
    cin >> a;
    sum += a;
    ans += r[sum % m];
    r[sum % m]++;
  }
  cout << ans << endl;
  return 0;
}
