text: #include <bits/stdc++.h>
  #define INF 2000000000
  using namespace std;
  typedef long long ll;
  int read(){
      int f = 1, x = 0;
      char c = getchar();
      while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
      while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
      return f * x; 
  }
  
  struct TreeNode {
      int val;
      TreeNode *left;
      TreeNode *right;
      TreeNode(int x) : val(x), left(NULL), right(NULL) {}
  };
  
  bool isLeaf(TreeNode* root) {
      return root->left == NULL && root->right == NULL;
  }
  
  struct ListNode {
      int val;
      ListNode *next;
      ListNode(int x) : val(x), next(NULL) {}
  };
  
  class Solution {
  public:
      bool circularArrayLoop(vector<int>& nums) {
          int n = nums.size();
          for (int i = 0; i < n; ++i) {
              if (!nums[i]) continue;
              int flag = nums[i] > 0 ? 1: -1;
              int cur = i, st = 0;
              bool ok = true;
              do{
                  int nxt = (cur + (nums[cur] % n) + n) % n;
                  if (nums[cur] * flag < 0) 
                      ok = false;
                  nums[cur] = 0, cur = nxt;
                  ++st;
              }while (nums[cur]);
              if (ok && st > 1 && cur == i)
                  return true;
          }
          return false;
      }
  };
  Solution sol;
  void init(){
      
  }
  void solve(){
      // sol.convert();
  }
  int main(){
      init();
      solve();
      return 0;
  }
  