#define taskname "data" #include #define FOR(i, a, b) for(int i = a ; i <= b ; ++i) #define FOD(i, a, b) for(int i = a ; i >= b ; --i) #define FRSZ(i, a) for(int i = 0 ; i < a.size(); ++i) #define FDSZ(i, a) for(int i = a.size() - 1 ; i >= 0 ; --i) #define RPSZ(i, a) for(int i = 1 ; i < a.size(); ++i) #define debug(x) cout << #x << " = " << x << endl; #define debugvi(x) {FRSZ(_, x) cout << x[_] << " " ; cout << endl;} #define debugarr(x, n) {FOR(_, 1, n) cout << x[_] << " " ; cout << endl;} #define ALL(x) (x).begin(), (x).end() #define Bit(x, i) ((x >> (i - 1)) & 1) #define NumBit(x) __builtin_popcount(x) #define SET(x) memset(x, - 1, sizeof x); #define BIG(x) memset(x, INF, sizeof x); #define CLR(x) memset(x, 0, sizeof x); #define NET(x) memset(x, 1, sizeof x); #define fi first #define se second using namespace std; template void Read(T &x){ bool neg = 0; x = 0; char ch; do{ch = getchar();} while(!isdigit(ch) && ch != '-'); if (ch == '-'){ neg = 1; ch = getchar(); } do{x = x * 10 + ch - 48; ch = getchar();} while(isdigit(ch)); if (neg) x = -x;} template void Write(T x){ int cnt = 0; char ch[32]; if (x < 0) { putchar('-'); x = -x; } do{ch[++cnt] = x % 10 + 48; x /= 10;} while(x); FOD(i, cnt, 1) putchar(ch[i]);} template void Writesp(T x){ Write(x); putchar(' ');} template void Writeln(T x){ Write(x); putchar('\n');} typedef int64_t ll; typedef vector BigNum; const int MAX = 101; const int BASE = 10000; int n; ll a[MAX]; ll Power[50]; /* -------------------------------BigNum------------------------------*/ void Print(BigNum x){ Write(x.back()); for(int i = x.size() - 2; i >= 0 ; --i) printf("%04d", x[i]); return; } bool operator < (BigNum x, BigNum y){ if (x.size() != y.size()) return x.size() < y.size(); FDSZ(i, x) if (x[i] != y[i]) return x[i] < y[i]; return 0; } BigNum Convert(ll x){ BigNum ans; do{ans.push_back(x % BASE); x /= BASE;} while(x); return ans; } BigNum operator + (const BigNum x, const BigNum y){ int carry = 0; BigNum ans; for(int i = 0 ; i < max(x.size(), y.size()) ; ++i){ if (i < x.size()) carry += x[i]; if (i < y.size()) carry += y[i]; ans.push_back(carry % BASE); carry /= BASE; } if (carry) ans.push_back(carry); return ans; } BigNum operator + (const BigNum x, const ll y){ BigNum z = Convert(y); return x + z; } BigNum operator - (BigNum x, BigNum y){ bool neg = 0; if (x < y) { BigNum tmp = x; x = y; y = tmp; neg = 1; } int carry = 0; BigNum ans; FRSZ(i, x){ int s = x[i] - carry; if (i < y.size()) s -= y[i]; if (s < 0) s += BASE, carry = 1; else carry = 0; ans.push_back(s); } while(ans.size() > 1 && ans.back() == 0) ans.pop_back(); if (neg) ans.back() = -ans.back(); return ans; } BigNum operator * (const BigNum x, const BigNum y){ int carry; BigNum ans(x.size() + y.size() + 5, 0); FRSZ(i, x){ carry = 0; FRSZ(j, y){ int id = i + j; ans[id] += x[i] * y[j] + carry; carry = ans[id] / BASE; ans[id] %= BASE; } ans[i + y.size()] += carry; } while(ans.size() > 1 && ans.back() == 0) ans.pop_back(); return ans; } BigNum operator * (const BigNum x, const int y){ int carry = 0; BigNum ans; FRSZ(i, x){ carry += x[i] * y; ans.push_back(carry % BASE); carry /= BASE; } if (carry) ans.push_back(carry); return ans; } BigNum operator / (const BigNum x, const BigNum y){ BigNum c, t; FDSZ(i, x){ t.insert(t.begin(), x[i]); int l = 1, r = BASE - 1; while(l <= r){ int mid = (l + r) >> 1; if (t < (y * mid)) r = mid - 1; else l = mid + 1; } c.insert(c.begin(), r); t = t - (y * r); } while(c.size() > 1 && !c.back()) c.pop_back(); return c; } /* -------------------------------BigNum------------------------------*/ void Enter(){ Read(n); FOR(i, 1, n) Read(a[i]); } void Init(){ Power[0] = 1; FOR(i, 1, 40) Power[i] = Power[i - 1] * 2; } BigNum Calc(ll x){ if (x == 1) return Convert(1); ll ans; FOR(i, 0, 40) if (x % Power[i] == 0 && Power[i] < x) ans = Power[i]; //debug(ans) BigNum tmp = Convert(x) / Convert(ans); return Calc(ans) * tmp + 1; } int main(int argc, char const *argv[]) { Enter(); Init(); BigNum ans; ans.push_back(0); FOR(i, 1, n) ans = ans + Calc(a[i]); Print(ans); return 0; }