#include using namespace std; typedef long long ll; const int off = (1 << 18); const ll mod = 1e9 + 7; ll n, a[off], ans; int T[2*off], S[2*off]; void prop(int w, int 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(int p, int k, int beg, int end, int w, int len) { if(T[w]) prop(w, len); if(p==beg && k==end) return S[w]; int 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(int p,int k, int beg, int end, int w, int val, int len) { if(T[w]) prop(w,len); if(p==beg && k==end) {T[w]=val; S[w]=(1ll*val*len)%mod; return;} int 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(int poc, int kon){ return query(poc, kon+1, 0, off, 1, off); } int bs(int poc, int kon, ll val){ if (poc == kon - 1) return poc; int sr = (poc + kon) / 2; if (T[sr + off] <= val) return bs(sr,kon,val); else return bs(poc, sr, val); } void set_val(int poc, int 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 (int i = 1; i <= n; i ++){ cin >> a[i]; } set cutters; for (int 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 (int i = 0; i < (int)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 << "\n"; return 0; }