#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
const long long mod = 998244353;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<int> r(m);
  long long aa = 0, ai, ans = 0;
  r[0] = 1;
  for (int i = (0); i < (n); i++) {
    cin >> ai;
    aa += ai;
    aa %= m;
    ans += r[aa];
    r[aa]++;
  }
  cout << ans << endl;
}
