fork download
  1. // Errichto
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
  5. #define RI(i,n) FOR(i,1,(n))
  6. #define REP(i,n) FOR(i,0,(n)-1)
  7.  
  8. const int mod = 1e9 + 7;
  9.  
  10. int main() {
  11. int n;
  12. scanf("%d", &n);
  13. long long s = 0;
  14. RI(i, n) {
  15. int a;
  16. scanf("%d", &a);
  17. if(n == 1) {
  18. printf("%d\n", a);
  19. return 0;
  20. }
  21. s = (s + (long long) a * (i + 1)) % mod;
  22. }
  23. REP(_, n - 2) s = 2 * s % mod;
  24. printf("%d\n", (int) s);
  25. return 0;
  26. }
  27.  
Time limit exceeded #stdin #stdout 5s 3456KB
stdin
Standard input is empty
stdout
Standard output is empty