#include using namespace std; using ll = long long; #define SPEED cin.tie(0);ios::sync_with_stdio(false); template class SparseTable{ public: Operator Op; using typeNode = decltype(Op.unitNode); vector node; vector idx; size_t depth; size_t length; SparseTable(const vector& vec) { for(depth = 0;(1<>1] + 1; } //[l,r) typeNode get(int l,int r) { int bit = idx[r-l]; return Op.funcNode(node[bit*length+l],node[bit*length+r - (1< struct nodeGCD { typeNode unitNode = 0; typeNode funcNode(typeNode l,typeNode r){return ((r == 0) ? l : funcNode(r, l % r));} }; // solution by binary search in arbitary range on disjn sparse table int main() { SPEED ll N; cin >> N; vector A(N+1,1); for(int i = 0; i < N; ++i) cin >> A[i]; SparseTable> st(A); ll ans=0; int r=1; for(int i=0; i