#include <iostream> 
#include <vector> 
using namespace std;

enum class type {
  vector_type,
  integer_type
};

// Object can either be an Integer or Vector<Object> 
class Object {
public:
  type type_;
  vector<Object> vec_;
  int num_;

  Object(): type_(type::integer_type)
  {
  }

  Object(const Object& other): type_(other.type_)
  {
    if(other.type_ == type::vector_type)
      vec_ = other.vec_;
    else
      num_ = other.num_;
  }

  //Object(const vector<int> &vec): type_(type::vector_type) {
  //    for (int i = 0; i < vec.size(); i++) {
  //    	vec_.push_back(Object(vec[i]));
  //    }
  //}

  Object(const vector<int> &vec): type_(type::vector_type), 
                                  vec_(vec.begin(), vec.end()) {
  }
  
  Object& operator=(const Object &other) {
    type_ = other.type_;
    if(other.type_ == type::vector_type)
      vec_ = other.vec_;
    else
      num_ = other.num_;
    return *this;
  }
  
  Object(const vector<Object> &vec) {
  	type_ = type::vector_type;
  	vec_ = vec;
  }
  
  Object(int num): type_(type::integer_type),
      num_(num)
  {
  }
};

int getSum_internal(Object &o, int &sum) {
	for (int i = 0; i < o.vec_.size(); i++) {
		if (o.vec_[i].type_ == type::integer_type) {
			sum += o.vec_[i].num_;
		}
		
		if (o.vec_[i].type_ == type::vector_type) {
			getSum_internal(o.vec_[i], sum);
		}
	}
}

int getSum(Object &o) {
	int sum = 0;
	getSum_internal(o, sum);
	return sum;
}

int main() {
  // to construct somth like that: [1,2, [3, [4,5], 6], 7] 
  Object o1(vector<int>({1,2}));
  Object o2(vector<int>({3}));
  Object o3(vector<int>({4,5}));
  Object o4(vector<int>({6}));
  Object o5(vector<Object>({o2,o3,o4}));
  Object o6(vector<int>({7}));
  Object o(vector<Object>({o1,o5,o6}));

  cout << getSum(o) << endl;
  
  return 0;
}