output_description: If it is possible to remove all the stones from the boxes, print `YES`.
  Otherwise, print `NO`.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 … A_N
attempt: 
  n = int(input())
  a = [int(i) for i in input().split()]
  
  def get_inv_diff(a):
      prev_val = a[-1]
      idx_lst = []
      for idx, cur_val in enumerate(a):
          # print("cur,pre",cur_val,prev_val)
          if cur_val <= prev_val:
              idx_lst.append(idx)
              if idx != 0 and prev_val - cur_val > 3:
                  for prev_val - cur_val / 4:
                      idx_lst.append(idx)
              # print("detect!")
          prev_val = cur_val
      return idx_lst
  
  def check_sum(a):
  
      sum = 0
      for val in a:
          sum += val
      cmp = [i+1 for i in range(n)]
      cmp_sum = 0
      for val in cmp:
          cmp_sum += val
  
      if sum % cmp_sum != 0:
          return -1
      else:
          result = sum / cmp_sum
          return result
  
  result = check_sum(a)
  if result == -1:
      print("NO")
  else:
      indices = get_inv_diff(a)
      if len(indices) != result:
          print("NO")
      else:
          # print("indices:", indices)
          test_lst = [0 for i in range(n)]
          for begin_idx in indices:
              for count in range(n):
                  # print("count:",count)
                  test_lst[(begin_idx + count) % n] += count+1
  
              # print(test_lst)
  
          if test_lst == a:
              print("YES")
          else:
              print("NO")
  
problem_description: Statement
  
  There are N boxes arranged in a circle. The i-th box contains A_i stones.
  
  Determine whether it is possible to remove all the stones from the boxes by
  repeatedly performing the following operation:
  
    * Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.
  
  Note that the operation cannot be performed if there is a box that does not
  contain enough number of stones to be removed.
samples: [{"input": "5\n    4 5 1 2 3", "output": "YES\n    \n\nAll the stones can be removed in one operation by selecting the second box.\n\n* * *"}, {"input": "5\n    6 9 12 10 8", "output": "YES\n    \n\n* * *"}, {"input": "4\n    1 2 3 1", "output": "NO"}]