#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,i,j,c,d,an=0,k,mod;
    mod=1000000007;
    cin>>n;
    ll ar[n+2];
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    for(i=0;i<60;i++)
    {
        k=(1LL<<i);
        c=0;
        d=0;
        for(j=0;j<n;j++)
        {
            if((ar[j] & k)==0)
                c++;
            else
                d++;
        }
        an=an+((k%mod)*((c*d)%mod))%mod;
        an=an%mod;
    }
     cout<<an<<endl;
}

#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
#define F first
#define S second

const int sz = 1e5+5;
int n, m, a[sz];

void solve(){
    cin >> n >> m;
    for(int i = 0; i < n; ++i) cin >> a[i];


    ll ans = 0;
    map<int, int> cnt;
    cnt[0] = 1;
    int sum = 0;
    for(int i = 0; i < n; ++i){
        sum = (sum + a[i]) % m;
        ans += cnt[sum];
        cnt[sum]++;
    }

    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}