#include using namespace std; typedef long long ll; const ll off = (1 << 18); const ll mod = 1e9 + 7; ll n, a[off], ans; ll T[2*off + 7], S[2*off + 7]; void prop(ll w, ll len) { if(w>=off) return; T[w*2]=T[w*2+1]=T[w]; S[w*2]=S[w*2+1]=(1ll*T[w]*len/2); S[w]=(1ll*S[w*2]+1ll*S[w*2+1])%mod; } ll query(ll p, ll k, ll beg, ll end, ll w, ll len) { if(T[w]) prop(w, len); if(p==beg && k==end) return S[w]; ll mid = (beg+end)/2; if(k<=mid) return query(p,k,beg,mid,w*2,len/2); if(p>=mid) return query(p,k,mid,end,w*2+1,len/2); return (query(p,mid,beg,mid,w*2,len/2) + query(mid,k,mid,end,w*2+1,len/2))%mod; } void ustaw(ll p,ll k, ll beg, ll end, ll w, ll val, ll len) { if(T[w]) prop(w,len); if(p==beg && k==end) {T[w]=val; S[w]=(1ll*val*len)%mod; return;} ll mid = (beg+end)/2; if(k<=mid)ustaw(p,k,beg,mid,w*2,val,len/2); else if(p>=mid) ustaw(p,k,mid,end,w*2+1, val, len/2); else { ustaw(p,mid,beg,mid,w*2,val, len/2); ustaw(mid,k,mid,end,w*2+1,val, len/2); } S[w]=(S[w*2]+S[w*2+1])%mod; } ll query(ll poc, ll kon){ return query(poc, kon+1, 0, off, 1, off); } ll bs(ll poc, ll kon, ll val){ if (poc == kon - 1) return poc; ll sr = (poc + kon) / 2; if (T[sr + off] < val) return bs(sr,kon,val); else return bs(poc, sr, val); } void set_val(ll poc, ll kon, ll val){ ustaw(poc, bs(poc, kon + 1, val)+1, 0,off,1,val,off); } int main(){ ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); cin >> n; for (ll i = 1; i <= n; i ++){ cin >> a[i]; } set cutters; for (ll i = n; i >= 1; i --){ ll x = a[i]; vector to_delete; vector > posses = {{i, a[i]}}; for (auto e : cutters){ if (x == 1LL) break; ll G = __gcd(x, a[e]); if (G == x) to_delete.push_back(e); else posses.push_back({e, x = G}); } posses.push_back({n + 1, 0LL}); /*/ cout << i << ": "; for (auto e : posses) cout << "(" << e.first << ", " << e.second << ") "; cout << endl; /*/ set_val(i, n, a[i]); for (ll i = 0; i < (ll)posses.size() - 1; i ++){ ans += posses[i].second * query(posses[i].first, posses[i + 1].first - 1); ans %= mod; } for (auto e : to_delete) cutters.erase(e); cutters.insert(i); } cout << ans % mod << "\n"; return 0; }