#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  map<int, int> h;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    if (i) a[i] += a[i-1];
    a[i] %= m;
    ++h[a[i]];
  }
  for (const auto &e: h) {
    if (e.first == 0) continue;
    ans += 1LL*e.second*(e.second-1)/2;
  }
  ans += 1LL*h[0]*(h[0]+1)/2;
  printf("%lld", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N, M;
ll A[100010];

int main(int argc, char **argv)
{
	cin >> N >> M;
	REP(i, N) cin >> A[i];
	A[0] %= M;
	REP(i, N-1)
		(A[i+1] += A[i]) %= M;

	map<ll, ll> m;
	REP(i, N)
		++m[A[i]];

	ll res{0};
	for (auto &p : m)
	{
		if (p.first == 0)
			res += p.second;
		res += p.second * (p.second-1) / 2;
	}

	std::cout << res << std::endl;
}
