#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const double pi = 3.14159265358979323846;
const int inf = 1e9;
const long long INF = 5e18;
int main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(false);
  long long n, m, ans = 0, cnt = 0, a[100005] = {};
  cin >> n >> m;
  map<int, int> mp;
  mp[0]++;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    a[i] += a[i - 1];
    mp[a[i] % m]++;
  }
  for (auto p : mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}
