fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int mx = 1e5;
  5. int a[mx+5];
  6.  
  7. int main() {
  8. int n, x, y, ans = 0;
  9. cin >> n;
  10. for (int i = 1; i < n; i++) cin >> a[i];
  11. cin >> x >> y;
  12. for (int i = x; i < y; i++) ans += a[i];
  13. cout << ans << endl;
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0s 4472KB
stdin
3
5 6
1 3
stdout
11