struct Tree {
  int *t, n;

  Tree( int n ) : n(n) {
    t = new int[2 * n]();
  }

  void change( int i, int x ) {
    t[i += n] = x;
    for (i /= 2; i > 0; i /= 2)
      t[i] = t[2 * i] + t[2 * i + 1];
  }

  int get( int l, int r ) {
    int res = 0;
    for (l += n, r += n; l <= r; l >>= 1, r >>= 1) {
      if ((l & 1) == 1) res += t[l++];
      if ((r & 1) == 0) res += t[r--];
    }
    return res;
  }
};