#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 5e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll n, a[100010], rui[100010], m, ans;
map<ll, ll> mp;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    rui[i + 1] = rui[i] + a[i];
    rui[i + 1] %= m;
  }
  mp[0] = 1;
  for (int i = 0; i < n; i++) {
    ans += mp[rui[i]];
    mp[rui[i]]++;
  }
  cout << ans << endl;
  return 0;
}
