#include using namespace std; //*/ #include using namespace atcoder; //*/ #define rep(i,n) for(int i=0;i; using ll = long long; using ull = unsigned long long; //*/ template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef pair pii; typedef pair pll; typedef vector vll; typedef vector vint; int op(int a,int b){return a+b;} int e(){return 0;} void solve(){ /*/ int n; cin >> n; vint a(n); rep(i,n) cin >> a[i]; mint ans = 0,two = 2; rep(i,n) ans += (mint)(a[i])*two.pow(n-1); cout << ans.val() << endl; /*/ ll n,q; cin >> n >> q; string s; cin >> s; segtree d(n),r(n); rep(i,n){ if(s[i] == 'D') d.set(i,1); else r.set(i,1); } rep(ssss,q){ ll h,w,p; cin >> h >> w >> p; //swap(h,w); auto f = [&](ll x)->pair{ x = p+x; pair res = {0,0}; res.first = (x/n)*d.all_prod(); res.second = (x/n)*r.all_prod(); if(x%n){ res.first += d.prod(0,x%n); res.second += r.prod(0,x%n); } if(p){ res.first -= d.prod(0,p); res.second -= r.prod(0,p); } return res; }; ll ac = 4e10,wa = 0; while(ac-wa>1){ ll mid= (ac+wa)/2; auto [H,W] = f(mid); if(H >= h || W >= w) ac = mid; else wa = mid; } cout << (ac+p)%n << endl; } //*/ } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; //cin >> t; rep(_,t) solve(); }