#include <iostream>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    ll cs = 0;
    map<ll, ll> modcount;
    modcount[0] = 1;
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        cs += a;
        cs %= m;
        ans += modcount[cs];
        modcount[cs]++;
    }
    cout << ans << endl;
    return 0;
}
