fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int mod = 1e9+7;
  6.  
  7. const int N = 1e5+5;
  8.  
  9. int n;
  10. long long a[N];
  11. long long pref_mul[N];
  12.  
  13. int fastP(int b, int e){
  14. if(!e)
  15. return 1;
  16. if(e & 1)
  17. return b * 1ll * fastP(b * 1ll * b % mod, e >> 1) % mod;
  18. return fastP(b * 1ll * b % mod, e >> 1) % mod;
  19. }
  20.  
  21. int main(){
  22. cin >> n;
  23. for(int i = 1; i <= n; i++){
  24. cin >> a[i];
  25. }
  26. pref_mul[0] = 1;
  27. for(int i = 1; i <= n; i++){
  28. pref_mul[i] = pref_mul[i - 1] * a[i];
  29. pref_mul[i] %= mod;
  30. }
  31. int to = ((n+1)/2) + 1;
  32. long long sum = 0;
  33. for(int i = 1; i <= to; i++){
  34. sum += (pref_mul[i + n/2 - 1] * fastP(pref_mul[i - 1] , mod - 2)) % mod;
  35. sum %= mod;
  36. }
  37. cout << sum << "\n";
  38. }
  39.  
Success #stdin #stdout 0s 4476KB
stdin
Standard input is empty
stdout
1