#pragma GCC optimize("O3,unroll-loops")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define el cout<<"\n"
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define f0(i,n) for(int i=0;i<n;i++)
#define fl(i,n) for(int i=1;i<=n;i++)
#define fz(i,a,n,z) for(int i=a;i<n;i+=z)
#define rep(i,a,n,z) for(int i=a;i>n;i-=z)
#define faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file(name) freopen(name".inp","r",stdin);freopen(name".out","w",stdout);
const int N = 2e5 + 5;
const int maxn = 1e6 + 1;
const int MOD = 1e9 + 7;
int lt[25];
void SinhLuyThua() {
lt[0] = 1;
for (int i = 1; i <= 20; ++i) {
lt[i] = lt[i - 1] * 2;
}
}
int A[N], T[N];
int main() {
faster
SinhLuyThua();
int n;
cin >> n;
T[0] = 0;
for (int i = 1; i <= n; ++i) {
cin >> A[i];
T[i] = T[i - 1] + A[i];
}
ll res = 0;
if (n <= 5000) {
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; ++j) {
for (int k = 20; k >= 0; --k) {
if ((T[j] - T[i - 1]) % lt[k] == 0) {res = res % MOD + lt[k] % MOD; break;}
}
}
}
}
else
{
map<int, int> D;
int maxLuyThua = lower_bound(lt, lt + 20, T[n]) - lt;
if (T[n] < lt[maxLuyThua]) {
maxLuyThua--;
}
int cnt, m = 0;
for (int i = maxLuyThua; i >= 0; --i) {
D.clear();
D[0] = 1;
for (int j = 1; j <= n; ++j) {
D[T[j] % lt[i]]++;
}
cnt = 0;
for (int j = 0; j < lt[i]; ++j) {
cnt += D[j] * (D[j] - 1) / 2;
}
res += (cnt - m) * lt[i];
m = cnt;
}
}
cout << res;
}
/*-----------------------END-----------------------*/