#include <bits/stdc++.h>
using namespace std;
const long MOD = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long> a(n);
  vector<vector<long>> v(n, vector<long>(n, 0));
  map<long, long> modmap;
  long b = 0;
  long ans = 0;
  modmap[b] = 1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b = (b + a[i]) % m;
    ans += modmap[b]++;
  }
  cout << ans;
  return 0;
}
