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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  unordered_map<int, int>mp;
  int n, m;
  cin >> n >> m;
  mp[0] = 1;
  ll ans = 0;
  ll sum = 0;
  for (int i = 0; i < n; i++){
    int x;
    cin >> x;
    sum += x;
    sum %= m;
    ans += mp[sum];
    mp[sum]++;            
  }
  cout << ans << "\n";
  return 0;
}