import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class C {
    public static void main(String[] args) throws IOException {
        new C().solve();
    }

    static final boolean DEBUG = System.getProperty("ONLINE_JUDGE") == null;

    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");

    void solve() throws IOException {
        br = new BufferedReader(new InputStreamReader(DEBUG ? new FileInputStream("input.txt") : System.in));
        int n = nextInt();
        boolean[] ok = new boolean[n];
        for (int i = 0; i < n; i++) {
            ok[i] = nextInt() == 1;
        }
        br.close();
        boolean res = find(n, ok);
        PrintWriter pw = new PrintWriter(System.out);
        pw.println(res ? "YES" : "NO");
        pw.close();
    }

    List<Integer> findPrimes(int n) {
        boolean[] m = new boolean[n + 1];
        int up = Math.min(n, (int) Math.sqrt(n + 1));
        for (int i = 2; i <= up; i++) {
            if (!m[i]) {
                int j = i + i;
                while (j <= n) {
                    m[j] = true;
                    j += i;
                }
            }
        }
        List<Integer> primes = new ArrayList<Integer>();
        if (n >= 4) {
            m[4] = false;
        }
        for (int i = 3; i <= n; i++) {
            if (!m[i] && n % i == 0) {
                primes.add(i);
            }
        }
        return primes;
    }

    boolean find(int n, boolean[] ok) {
        List<Integer> primes = findPrimes(n);
        int[] next = new int[n];
        int lastGoodInd = n + 1;
        for (int i = n - 1; i >= 0; i--) {
            if (ok[i]) {
                lastGoodInd = i;
            }
            next[i] = lastGoodInd;
        }
        if (lastGoodInd == n + 1) {
            return false;
        }
        int[] p = new int[primes.get(primes.size() - 1)];
        for (int k : primes) {
            final int delta = n / k;
            p[0] = 0;
            for (int i = 1; i < k; i++) {
                p[i] = p[i - 1] + delta;
            }
            while (p[0] < delta) {
                int max = 0;
                for (int i = 0; i < k; i++) {
                    final int nextInd = p[i] + max;
                    if (nextInd >= n) {
                        break;
                    }
                    if (!ok[nextInd]) {
                        max = Math.max(max, next[nextInd] - p[i]);
                        if (max >= delta) {
                            break;
                        }
                    }
                }
                if (max == 0) {
                    return true;
                }
                for (int i = 0; i < k; i++) {
                    p[i] += max;
                }
            }
        }
        return false;
    }

    String nextToken() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
}


import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class C {
    public static void main(String[] args) throws IOException {
        new C().solve();
    }

    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");

    void solve() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        int n = nextInt();
        boolean[] ok = new boolean[n];
        for (int i = 0; i < n; i++) {
            ok[i] = nextInt() == 1;
        }
        br.close();
        boolean res = find(n, ok);
        PrintWriter pw = new PrintWriter(System.out);
        pw.println(res ? "YES" : "NO");
        pw.close();
    }

    List<Integer> findPrimes(int n) {
        boolean[] m = new boolean[n + 1];
        int up = Math.min(n, (int) Math.sqrt(n + 1));
        for (int i = 2; i <= up; i++) {
            if (!m[i]) {
                int j = i + i;
                while (j <= n) {
                    m[j] = true;
                    j += i;
                }
            }
        }
        List<Integer> primes = new ArrayList<Integer>();
        if (n >= 4) {
            m[4] = false;
        }
        for (int i = 3; i <= n; i++) {
            if (!m[i] && n % i == 0) {
                int other = n / i;
                if (other < 3 || i < other) {
                    primes.add(i);
                }
            }
        }
        return primes;
    }

    boolean find(int n, boolean[] ok) {
        List<Integer> primes = findPrimes(n);
        int[] next = new int[n];
        int lastGoodInd = n + 1;
        for (int i = n - 1; i >= 0; i--) {
            if (ok[i]) {
                lastGoodInd = i;
            }
            next[i] = lastGoodInd;
        }
        if (lastGoodInd == n + 1) {
            return false;
        }
        int[] p = new int[primes.get(primes.size() - 1)];
        for (int k : primes) {
            final int delta = n / k;
            p[0] = 0;
            for (int i = 1; i < k; i++) {
                p[i] = p[i - 1] + delta;
            }
            while (p[0] < delta) {
                int max = 0;
                for (int i = 0; i < k; i++) {
                    final int nextInd = p[i] + max;
                    if (nextInd >= n) {
                        break;
                    }
                    if (!ok[nextInd]) {
                        max = Math.max(max, next[nextInd] - p[i]);
                        if (max >= delta) {
                            break;
                        }
                    }
                }
                if (max == 0) {
                    return true;
                }
                for (int i = 0; i < k; i++) {
                    p[i] += max;
                }
            }
        }
        return false;
    }

    String nextToken() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
    public static boolean check(boolean[] A, int i) {
        int n = A.length;
        int dif = n / i;
        boolean[] visited = new boolean[n];
        for (int j = 0; j < n; j++) {
            if (!A[j] || visited[j])
                continue;
            int k = j + dif;
            boolean can = true;
            while (k != j) {
                k %= n;
                visited[k] = true;
                can &= A[k];
                k += dif;
            }
            if (can)
                return true;
        }
        return false;
    }

    public static boolean Can(boolean[] A) {
        int n = A.length;
        for (int i = 3; i <= n; i++) {
            if (n % i != 0)
                continue;
            boolean can = check(A, i);
            if (can)
                return true;
        }
        return false;
    }

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        boolean[] A = new boolean[n];
        String[] S = in.readLine().split(" ");
        for (int i = 0; i < n; i++)
            if (S[i].equals("1"))
                A[i] = true;
            else
                A[i] = false;
        if (Can(A))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static boolean check(boolean[] A, int i) {
        int n = A.length;
        int dif = n / i;
        boolean[] visited = new boolean[n];
        for (int j = 0; j < n; j++) {
            if (!A[j] || visited[j])
                continue;
            int k = j + dif;
            boolean can = true;

            while (k != j) {
                visited[k] = true;
                can &= A[k];
                k += dif;
                k %= n;
            }
            if (can)
                return true;
        }
        return false;
    }

    public static boolean Can(boolean[] A) {
        int n = A.length;
        for (int i = 3; i <= n; i++) {
            if (n % i != 0)
                continue;
            boolean can = check(A, i);
            if (can)
                return true;
        }
        return false;
    }

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        boolean[] A = new boolean[n];
        String[] S = in.readLine().split(" ");
        for (int i = 0; i < n; i++)
            if (S[i].equals("1"))
                A[i] = true;
            else
                A[i] = false;
        if (Can(A))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
    public static boolean check(boolean[] A, int i) {
        int n = A.length;
        int dif = n / i;
        boolean[] visited = new boolean[n];
        for (int j = 0; j < n; j++) {
            if (!A[j] || visited[j])
                continue;
            int k = (j + dif) % n;
            boolean can = true;
            while (k != j) {
                visited[k] = true;
                can &= A[k];
                k += dif;
                k %= n;
            }
            if (can)
                return true;
        }
        return false;
    }

    public static boolean Can(boolean[] A) {
        int n = A.length;
        for (int i = 3; i <= n; i++) {
            if (n % i != 0)
                continue;
            boolean can = check(A, i);
            if (can)
                return true;
        }
        return false;
    }

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        boolean[] A = new boolean[n];
        String[] S = in.readLine().split(" ");
        for (int i = 0; i < n; i++)
            if (S[i].equals("1"))
                A[i] = true;
            else
                A[i] = false;
        if (Can(A))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.*;

public class C {

    MyScanner in;
    PrintWriter out;

    public static void main(String[] args) throws Exception {
        new C().run();
    }

    public void run() throws Exception {
        in = new MyScanner();
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    public void solve() throws Exception {
        int n = in.nextInt();
        boolean[] a = new boolean[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = (in.nextInt() == 1) ? true : false;
        }
        String ans = "NO";

        for (int k = 1; k < n; k++) {
            if ((n % k == 0) && (n / k >= 3)) {
                for (int i = 0; i < k; i++) {
                    boolean flag = true;
                    for (int j = 0; j < n / k; j++) {
                        if (!a[(i + j * k) % n]) {
                            flag = false;
                        }
                    }
                    if (flag) {
                        ans = "YES";
                    }
                }
            }
        }

        out.println(ans);
    }

    class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() throws Exception {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws Exception {
            if ((st == null) || (!st.hasMoreTokens())) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        int nextInt() throws Exception {
            return Integer.parseInt(next());
        }

        double nextDouble() throws Exception {
            return Double.parseDouble(next());
        }

        boolean nextBoolean() throws Exception {
            return Boolean.parseBoolean(next());
        }

        long nextLong() throws Exception {
            return Long.parseLong(next());
        }
    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * I=1 V=5 X=10 L=50 C=100 D=500 M=1000 IV 4, IX 9, XL 40, XC 90, CD 400, CM
 * 900.
 *
 * @author pttrung
 */
public class C {

    // public static long Mod = 1000000009;
    public static void main(String[] args) {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] data = new int[n];

        for (int i = 0; i < n; i++) {
            data[i] = in.nextInt();

        }
        boolean found = false;
        for (int i = 1; i * 3 <= n && !found; i++) {
            if (n % i == 0) {
                int val = n / i;

                for (int j = 0; j < i && !found; j++) {
                   // System.out.println("Start");
                    found = true;
                    for (int k = 0; k < val && found; k++) {
                     //   System.out.print( (j + k*i) + " ");
                        found = data[j + k * i] != 0;
                    }
                }
                //System.out.println();
            }
        }
        if (found) {
            out.println("YES");
        } else {
            out.println("NO");
        }
        out.close();
    }

//    public static int gcd(int a, int b) {
//        if (b == 0) {
//            return a;
//        }
//        return gcd(b, a % b);
//    }
    public static class Edge implements Comparable<Edge> {

        int node;
        long w;

        public Edge(int node, long w) {
            this.node = node;
            this.w = w;
        }

        @Override
        public int compareTo(Edge o) {
            if (w > o.w) {
                return 1;
            } else if (w == o.w) {
                return 0;
            }
            return -1;
        }
    }

//    static void check(Point a, Point b, ArrayList<Point> p, Point[] rec, int index) {
//        for (int i = 0; i < 4; i++) {
//            int m = (i + index) % 4;
//            int j = (i + 1 + index) % 4;
//            Point k = intersect(minus(b, a), minus(rec[m], rec[j]), minus(rec[m], a));
//            if (k.x >= 0 && k.x <= 1 && k.y >= 0 && k.y <= 1) {
//                Point val = new Point(k.x * minus(b, a).x, k.x * minus(b, a).y);
//                p.add(add(val, a));
//                // System.out.println(a + " " + b + " " + rec[i] + " " + rec[j]);
//                // System.out.println(add(val, a));
//            }
//        }
//    }
//
//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
//
//    static Point minus(Point a, Point b) {
//        return new Point(a.x - b.x, a.y - b.y);
//    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//
//    static double cross(Point a, Point b) {
//        return a.x * b.y - a.y * b.x;
//    }
//
//    static class Point {
//
//        double x, y;
//
//        Point(double x, double y) {
//            this.x = x;
//            this.y = y;
//        }
//
//        @Override
//        public String toString() {
//            return "Point: " + x + " " + y;
//        }
//    }
    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * I=1 V=5 X=10 L=50 C=100 D=500 M=1000 IV 4, IX 9, XL 40, XC 90, CD 400, CM
 * 900.
 *
 * @author pttrung
 */
public class C {

    // public static long Mod = 1000000009;
    public static void main(String[] args) {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int []data = new int[n];
        int gap = 0;
        int max = 0;
        for(int i = 0; i < n ; i++){
            data[i] = in.nextInt();
            if(data[i] == 0){
                gap++;
            }else{
                gap = 0;
            }
            max = Math.max(max, gap);
        }
        boolean found = false;
        for(int i = 1; i*3 <= n; i++){
            if(n % i == 0){
                int val = n/i;
                //System.out.println(val + " " + max + " " + i);
                if(val >= 3 && max < i){

                    found = true;
                    break;
                }
            }
        }
        if(found){
            out.println("YES");
        }else{
            out.println("NO");
        }
        out.close();
    }

//    public static int gcd(int a, int b) {
//        if (b == 0) {
//            return a;
//        }
//        return gcd(b, a % b);
//    }
    public static class Edge implements Comparable<Edge> {

        int node;
        long w;

        public Edge(int node, long w) {
            this.node = node;
            this.w = w;
        }

        @Override
        public int compareTo(Edge o) {
            if (w > o.w) {
                return 1;
            } else if (w == o.w) {
                return 0;
            }
            return -1;
        }
    }

//    static void check(Point a, Point b, ArrayList<Point> p, Point[] rec, int index) {
//        for (int i = 0; i < 4; i++) {
//            int m = (i + index) % 4;
//            int j = (i + 1 + index) % 4;
//            Point k = intersect(minus(b, a), minus(rec[m], rec[j]), minus(rec[m], a));
//            if (k.x >= 0 && k.x <= 1 && k.y >= 0 && k.y <= 1) {
//                Point val = new Point(k.x * minus(b, a).x, k.x * minus(b, a).y);
//                p.add(add(val, a));
//                // System.out.println(a + " " + b + " " + rec[i] + " " + rec[j]);
//                // System.out.println(add(val, a));
//            }
//        }
//    }
//
//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
//
//    static Point minus(Point a, Point b) {
//        return new Point(a.x - b.x, a.y - b.y);
//    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//
//    static double cross(Point a, Point b) {
//        return a.x * b.y - a.y * b.x;
//    }
//
//    static class Point {
//
//        double x, y;
//
//        Point(double x, double y) {
//            this.x = x;
//            this.y = y;
//        }
//
//        @Override
//        public String toString() {
//            return "Point: " + x + " " + y;
//        }
//    }
    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author jtimv
 */
import java.io.*;

public class Task {

    public static void main(String[] args) {
        new Task().main();
    }
    StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

    int nextInt() {
        try {
            in.nextToken();
        } catch (IOException ex) {
        }
        return (int) in.nval;
    }

    boolean checkThisOne(int[] a, int start, int step) {
        int vertexes=0;
        while (start < a.length) {
            if (a[start] == 0) {
                return false;
            }
            start += step;
            vertexes++;
        }
        return (vertexes >= 3);
    }

    boolean check(int[] a, int step) {
        for (int start = 0; start < step; start++) {
            if (checkThisOne(a, start, step)) {
                //System.out.println(start+" "+step);
                return true;
            }
        }
        return false;
    }

    void main() {
        int n = nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        for (int k = 1; k <= n; k++) {
            if ((n%k==0)&&check(a, k)) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author jtimv
 */
import java.io.*;

public class Task {

    public static void main(String[] args) {
        new Task().main();
    }
    StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

    int nextInt() {
        try {
            in.nextToken();
        } catch (IOException ex) {
        }
        return (int) in.nval;
    }

    boolean checkThisOne(int[] a, int start, int step) {
        int vertexes=0;
        while (start < a.length) {
            if (a[start] == 0) {
                return false;
            }
            start += step;
            vertexes++;
        }
        return (vertexes >= 3);
    }

    boolean check(int[] a, int step) {
        for (int start = 0; start < step; start++) {
            if (checkThisOne(a, start, step)) {
                return true;
            }
        }
        return false;
    }

    void main() {
        int n = nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        for (int k = 1; k <= n; k++) {
            if (check(a, k)) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


import java.util.Scanner;
import java.util.StringTokenizer;

/**
 *
 * @author dima
 */
public class Main {

    public static int cntOfOne(int[] mas,int n){
        int cnt=0;
        for(int i=0;i<n;i++){
            if(mas[i]==1) cnt++;
        }
        return cnt;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] mas = new int[n+1];

        for(int i=0;i<n;i++){
            mas[i]=in.nextInt();
        }
        int cnt = cntOfOne(mas, n);
        boolean bad = false;
        for(int k = 3;k<=cnt;k++){
            int del = n%k;
            if(del!=0) {
                continue;
            } else{
                del = n/k;
            }

            for(int start = 0;start<del;start++){
                bad = false;
                for(int j = start;j<n;j+=del){
                    if(mas[j]==0){
                        bad = true; break;
                    }
                }
                if(!bad){
                    break;
                }
            }
            if(!bad){
                break;
            }
        }
        if(!bad){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }

}


import java.util.Scanner;

/**
 *
 * @author dima
 */
public class Main {

    public static int cntOfOne(int[] mas,int n){
        int cnt=0;
        for(int i=0;i<n;i++){
            if(mas[i]==1) cnt++;
        }
        return cnt;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] mas = new int[n+1];

        for(int i=0;i<n;i++){
            mas[i]=in.nextInt();
        }
        int cnt = cntOfOne(mas, n);
        boolean bad = true;
        int rrr = 0;
        for(int k = 3;k<=cnt;k++){
            int del = n%k;
            if(del!=0) {
                continue;
            } else{
                del = n/k;
            }

            for(int start = 0;start<del;start++){
                bad = false;
                for(int j = start;j<n;j+=del){
                    if(mas[j]==0){
                        bad = true; break;
                    }
                }
                if(!bad){
                    break;
                }
            }
            if(!bad){
                rrr = k;
                break;
            }

        }
        if(!bad){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class RoundTableKnights implements Runnable {
    private void solve() throws IOException {
        int n = nextInt();
        int[] t = new int[n];
        for(int i = 0; i < n; ++i)
            t[i] = nextInt();

        for(int i = 3 ; i <= n; ++i)
        {
            if(n%i != 0)
                continue;

            int jump = n/3;
            for(int j = 0; j < n; ++j)
            {
                boolean ok = true;
                int c =0;
                for(int k = j; k < n ; k += jump)
                {
                    c++;
                    if(t[k] == 0)
                    {
                        ok = false;
                        break;
                    }
                }
                if(ok && c==i)
                {
                    writer.println("YES");
                    return;
                }

            }
        }
        writer.println("NO");

    }

    public static void main(String[] args) {
        new RoundTableKnights().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class RoundTableKnights implements Runnable {
    private void solve() throws IOException {
        int n = nextInt();
        int[] t = new int[n];
        for(int i = 0; i < n; ++i)
            t[i] = nextInt();

        for(int i = 3 ; i <= n; ++i)
        {
            if(n%i != 0)
                continue;

            int jump = n/i;
            for(int j = 0; j < n; ++j)
            {
                boolean ok = true;
                int c =0;
                for(int k = j; k < n ; k += jump)
                {
                    c++;
                    if(t[k] == 0)
                    {
                        ok = false;
                        break;
                    }
                }
                if(ok && c==i)
                {
                    writer.println("YES");
                    return;
                }

            }
        }
        writer.println("NO");

    }

    public static void main(String[] args) {
        new RoundTableKnights().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


//package round65;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class C {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = ni();
		}
		for(int p = 1;p <= n/3;p++){
			if(n % p == 0){
				outer:
				for(int i = 0;i < p;i++){
					for(int j = i;j < n;j += p){
						if(a[j] == 0){
							continue outer;
						}
					}
					out.println("YES");
					return;
				}
			}
		}
		out.println("NO");
	}

	void run() throws Exception
	{
//		int n = 100000;
//		StringBuilder sb = new StringBuilder(n + " ");
//		Random r = new Random();
//		for(int i = 0;i < n;i++){
//			sb.append(r.nextInt(2) + " ");
//		}
//		INPUT = sb.toString();
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		solve();
		out.flush();
	}

	public static void main(String[] args) throws Exception
	{
		new C().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;

public class Main {
	private static StreamTokenizer in = new StreamTokenizer(new BufferedReader(
			new InputStreamReader(System.in)));
	private static PrintWriter out = new PrintWriter(System.out);

	private static int nextInt() throws Exception {
		in.nextToken();
		return (int) in.nval;
	}

	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;
	}

	public static void main(String[] args) throws Exception {
		int n = nextInt(), t = n;
		a = new int[n];
		for (int i=0; i<n; i++) {
			a[i] = nextInt();
		}
		int[] cdf = new int[n];
		for (int i = 3; i * i < t; i++) {
			if (t % i == 0) {
				while (t % i == 0) {
					t /= i;
				}
				int u = n/i;
				Arrays.fill(cdf, 1);
				for (int offset = 0; offset < n; offset += u) {
					for (int j = 0; j < u; j++) {
						cdf[j] &= a[offset + j];
					}
				}
				for (int j=0; j<u; j++) {
					if (cdf[j] == 1) {
						out.println("YES");
						out.flush();
						return;
					}
				}
			}
		}
		if (n > 2) {
			if (n!=4 && n % 2 == 0) {
				t /= 2;
			}
			Arrays.fill(cdf, 1);
			int i = t;
			int u = n/i;
			for (int offset = 0; offset < n; offset += u) {
				for (int j = 0; j < u; j++) {
					cdf[j] &= a[offset + j];
				}
			}
			for (int j=0; j<u; j++) {
				if (cdf[j] == 1) {
					out.println("YES");
					out.flush();
					return;
				}
			}

		}
		out.println("NO");
		out.flush();
	}

	private static int[] a;

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;

public class Main {
	private static StreamTokenizer in = new StreamTokenizer(new BufferedReader(
			new InputStreamReader(System.in)));
	private static PrintWriter out = new PrintWriter(System.out);

	private static int nextInt() throws Exception {
		in.nextToken();
		return (int) in.nval;
	}

	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;
	}

	public static void main(String[] args) throws Exception {
		int n = nextInt(), t = n;
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		int[] cdf = new int[n];
		for (int i = 3; i <= t; i++) {
			if (t % i == 0) {
				while (t % i == 0) {
					t /= i;
				}
				int u = n / i;
				Arrays.fill(cdf, 1);
				for (int j=0; j<n; j++) {
					cdf[j%u] &= a[j];
				}
				for (int j=0; j<u; j++) {
					if (cdf[j] == 1) {
						out.println("YES");
						out.flush();
						return;
					}
				}
			}
		}
		out.println("NO");
		out.flush();
	}

	private static int[] a;

}


import java.util.*;

public class Main{
    private static boolean[] flag;
    private static int[] lst;
    private static int top;

    public static void init(){
        flag=new boolean[100001];
        lst=new int[100001];
        top=0;
        for(int i=0;i<100001;i++){
            flag[i]=true;
            lst[i]=0;
        }
        flag[0]=flag[1]=false;
        for(int i=2;i<100001;i++){
            if(flag[i]) lst[top++]=i;
            for(int j=0;j<top&&i*lst[j]<100001;j++){
                flag[i*lst[j]]=false;
                if(i%lst[j]==0) break;
            }
        }
    }

    private static List<Integer> run(int n){
        List<Integer> ret=new LinkedList<Integer>();

        for(int i=0;i<top&&lst[i]*lst[i]<=n;i++){
            if(n%lst[i]==0){
                while(n%lst[i]==0){
                    n/=lst[i];
                }
                ret.add(lst[i]);
            }
        }
        if(n!=1) ret.add(n);

        return ret;
    }

    public static void main(String[] args){
        Scanner cin=new Scanner(System.in);
        List<Integer> list;
        int[] a=new int[100001];
        boolean[] g=new boolean[100001];
        int n;
        init();
        n=cin.nextInt();
        for(int i=0;i<n;i++){
            a[i]=cin.nextInt();
        }
        list=run(n);
        boolean fail=true;
        Iterator<Integer> it=list.iterator();
        while(fail&&it.hasNext()){
            int p=it.next();
            if(p<3){
                continue;
            }
            p=n/p;
            int cnt=0;
            for(int i=0;i<p;i++) g[i]=true;
            for(int i=0;cnt<p&&i<n;i++){
                if(a[i]==0){
                    if(g[i%p]){
                        g[i%p]=false;
                        cnt++;
                    }
                }
            }
            if(cnt<p){
                fail=false;
                break;
            }
        }
        if(fail){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
}


import java.util.*;

public class Main{
    private static boolean[] flag;
    private static int[] lst;
    private static int top;

    public static void init(){
        flag=new boolean[100001];
        lst=new int[100001];
        top=0;
        for(int i=0;i<100001;i++){
            flag[i]=true;
            lst[i]=0;
        }
        flag[0]=flag[1]=true;
        for(int i=2;i<100001;i++){
            if(flag[i]) lst[top++]=i;
            for(int j=0;j<top&&i*lst[j]<100001;j++){
                flag[i*lst[j]]=false;
                if(i%lst[j]==0) break;
            }
        }
    }

    private static List<Integer> run(int n){
        List<Integer> ret=new LinkedList<Integer>();
        ret.add(1);

        for(int i=0;i<top&&lst[i]*lst[i]<=n;i++){
            if(n%lst[i]==0){
                while(n%lst[i]==0){
                    n/=lst[i];
                }
                ret.add(lst[i]);
            }
        }
        if(n!=1) ret.add(n);

        return ret;
    }

    public static void main(String[] args){
        Scanner cin=new Scanner(System.in);
        List<Integer> list;
        int[] a=new int[100001];
        boolean[] g=new boolean[100001];
        int n;
        init();
        n=cin.nextInt();
        for(int i=0;i<n;i++){
            a[i]=cin.nextInt();
        }
        list=run(n);
        boolean fail=true;
        Iterator<Integer> it=list.iterator();
        while(fail&&it.hasNext()){
            int p=it.next();
            if(n/p<3) break;
            for(int i=0;i<p;i++) g[i]=true;
            for(int i=0;i<n;i++){
                if(a[i]==0){
                    g[i%p]=false;
                }
            }
            for(int i=0;i<p;i++){
                if(g[i]){
                    fail=false;
                    break;
                }
            }
        }
        if(fail){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
}


import java.util.*;

public class Main{
    static int MAX=100005;
    static int[] a;
    static boolean[] flag;
    static int[] lst;
    static int top;

    static void init(){
        flag=new boolean[MAX];
        lst=new int[MAX];
        top=0;
        for(int i=0;i<MAX;i++){
            flag[i]=true;
        }
        flag[0]=flag[1]=false;
        for(int i=2;i<MAX;i++){
            if(flag[i]) lst[top++]=i;
            for(int j=0;j<top&&i*lst[j]<MAX;j++){
                flag[i*lst[j]]=false;
                if(i%lst[j]==0) break;
            }
        }
    }

    static List<Integer> hash(int n){
        List<Integer> ret=new LinkedList<Integer>();

        if(n%4==0) ret.add(4);

        for(int i=0;i<top&&lst[i]*lst[i]<=n;i++){
            if(n%lst[i]==0){
                ret.add(lst[i]);
                while(n%lst[i]==0){
                    n/=lst[i];
                }
            }
        }
        if(n!=1) ret.add(n);

        return ret;
    }

    public static void main(String[] args){
        Scanner cin=new Scanner(System.in);
        boolean[] vst;
        init();
        int n;

        n=cin.nextInt();
        a=new int[n];
        vst=new boolean[n];
        for(int i=0;i<n;i++){
            a[i]=cin.nextInt();
        }

        List<Integer> list=hash(n);
        Iterator<Integer> it=list.iterator();
        boolean fail=true;
        while(fail&&it.hasNext()){
            int p=it.next();
            if(p<3) continue;
            p=n/p;
            Arrays.fill(vst, false);
            int cnt=0;
            for(int i=0;i<n&&cnt<p;i++){
                if(a[i]==0){
                    if(!vst[i%p]){
                        cnt++;
                        vst[i%p]=true;
                    }
                }
            }
            if(cnt<p){
                fail=false;
                break;
            }
        }
        if(fail){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
}


import java.io.*;
import java.util.StringTokenizer;

public class Q71C implements Runnable{
    private void solve() throws IOException {
        int n = nextInt() ;
        boolean[] state  = new boolean[n];
        for(int i=0;i<n;i++){
            state[i] = (nextInt()==1);
        }
        for(int i = 1;i<=(n/3);i++){
            if(n%i==0){
                for(int s=0;s<i;s++){
                    boolean can = true;
                    for(int z=s;z<n;z+=i){
                        if(!state[z]){
                            can=false;
                            break;
                        }
                    }
                    if(can){
                        writer.print("YES");
                        return;
                    }
                }
            }
        }
        writer.print("NO");
    }

    public static void main(String[] args) {
        new Q71C().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {

            boolean oj = System.getProperty("ONLINE_JUDGE") != null;

            reader = oj ? new BufferedReader(new InputStreamReader(System.in)) :
                    new BufferedReader(new FileReader(new File("input.txt")));

            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.io.*;
import java.util.StringTokenizer;

public class Q71C implements Runnable{
    private void solve() throws IOException {
        int n = nextInt() ;
        boolean[] state  = new boolean[n];
        for(int i=0;i<n;i++){
            state[i] = (nextInt()==1);
        }
        for(int i = 2;i<=(n/3);i++){
            if(n%i==0){
                for(int s=0;s<i;s++){
                    boolean can = true;
                    for(int z=s;z<n;z+=i){
                        if(!state[z]){
                            can=false;
                            break;
                        }
                    }
                    if(can){
                        writer.print("YES");
                        return;
                    }
                }
            }
        }
        writer.print("NO");
    }

    public static void main(String[] args) {
        new Q71C().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {

            boolean oj = System.getProperty("ONLINE_JUDGE") != null;

            reader = oj ? new BufferedReader(new InputStreamReader(System.in)) :
                    new BufferedReader(new FileReader(new File("input.txt")));

            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.io.*;
import java.util.*;

public class CodeForce {
    /*
    private static boolean can(int h, int w, int l, int []arr) {
        int area = h * w;
        for(int i = 0; i < arr.length; i++) {
            if(arr[i] < l) continue;
            else if(arr[i] >= w) {
                int d = arr[i] / w;
                area -= (d * w);
            } else if(w - arr[i] >= l) {
                area -= arr[i];
            }
        }
        return area <= 0;
    }

    private void solve() throws IOException {
        int n = nextInt(), l = nextInt();
        int []arr = new int[n];
        int m = Integer.MIN_VALUE;
        for(int i = 0; i < n; i++) {
            int u = nextInt();
            arr[i] = u;
            if(u > m) m = u;
        }

        int max = 0;
        for(int h = 1; h <= n; h++)
            for(int w = 1; w <= Math.max(n, m); w++)
                if(can(h, w, l, arr) && h * w > max)
                    max = h * w;
        System.out.println(max);
    }
    */

    private void solve() throws IOException {
        int n = nextInt();
        int []arr = new int[n];
        for(int i = 0; i < n; i++)
            arr[i] = nextInt();
        boolean ret = false;
        int []v = new int[n];
        out:
        for(int i = 1; i <= n / 3; i++) {
            if(n % i > 0) continue;
            for(int j = 0; j < i; j++) v[j] = 1;
            for(int k = 0; k < n; k++) v[k % i] &= arr[k];
            for(int k = 0; k < n; k++) if(v[k] == 1) { ret = true; break out; }
        }

        if(ret) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        new CodeForce().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextLine() throws IOException {
        return reader.readLine();
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.io.*;
import java.util.*;

public class CodeForce {
    /*
    private void solve() throws IOException {
        int n = nextInt(), k = nextInt();
        int []arr = new int[n];
        int sum = 0;
        for(int i = 0; i < n; i++) {
            int u = nextInt();
            sum += u;
            arr[i] = u;
        }
        Arrays.sort(arr);
        double average = (double)sum / (double)n;
        int n_isum = 0, isum = 0, n_jsum = 0, jsum = 0;
        for(int i = 0; i < n && arr[i] <= average; i++)     { isum += arr[i]; n_isum++; }
        for(int j = n - 1; j >= 0 && arr[j] > average; j--) { jsum += arr[j]; n_jsum++; }
        double a = (double)isum / (double)n_isum;
        double b = (n_jsum == 0) ? a : (double)jsum / (double)n_jsum;
        double m = (double)jsum;
        double ua = 0.0, ub = m;
        while(Math.abs(a - b) > 10.e-9) {
            double kk = m * ((100.0 - k) / 100.0);
            a = (double)(isum + kk) / (double)n_isum;
            b = (double)(jsum - m)  / (double)n_jsum;
            if(a < b) {
                ua = m;
            } else {
                ub = m;
            }
            m = ua + (ub - ua) / 2.0;
        }
        System.out.println(a);
    }
    */
    /*
    private void solve() throws IOException {
        final int n = nextInt(), a = nextInt(), b = nextInt();
        int [][]arr = new int[n][2];
        int []c = new int[n];
        for(int i = 0; i < n; i++) {
            int u = nextInt();
            arr[i] = new int[2];
            arr[i][0] = u;
            arr[i][1] = i;
        }
        Arrays.sort(arr, new Comparator<int []>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                int x = o2[0] - o1[0];
                if(a == b) return o2[1] - o1[1];
                if(x != 0) return x;
                if(a > b) {
                    return o2[1] - o1[1];
                } else  {
                    return o1[1] - o2[1];
                }
            }
        });
        int s = (a >= b) ? 2 : 1;
        int u = (a >= b) ? b : a;
        for(int i = 0; i < u; i++)
            c[arr[i][1]] = s;
        s = s == 1 ? 2 : 1;
        int m = u == b ? a : b;
        for(int i = u; i < u + m; i++)
            c[arr[i][1]] = s;
        for(int i = 0; i < c.length; i++)
            System.out.print(c[i] + " ");
    }
    */
    /*
    private static boolean can(int h, int w, int l, int []arr) {
        int area = h * w;
        for(int i = 0; i < arr.length; i++) {
            if(arr[i] < l) continue;
            else if(arr[i] >= w) {
                int d = arr[i] / w;
                area -= (d * w);
            } else if(w - arr[i] >= l) {
                area -= arr[i];
            }
        }
        return area <= 0;
    }

    private void solve() throws IOException {
        int n = nextInt(), l = nextInt();
        int []arr = new int[n];
        int m = Integer.MIN_VALUE;
        for(int i = 0; i < n; i++) {
            int u = nextInt();
            arr[i] = u;
            if(u > m) m = u;
        }

        int max = 0;
        for(int h = 1; h <= n; h++)
            for(int w = 1; w <= Math.max(n, m); w++)
                if(can(h, w, l, arr) && h * w > max)
                    max = h * w;
        System.out.println(max);
    }
    */

    private void solve() throws IOException {
        int n = nextInt();
        boolean []arr = new boolean[n];
        for(int i = 0; i < n; i++) {
            int u = nextInt();
            if(u == 1) arr[i] = true;
        }
        boolean ret = false;
        out:
        for(int i = 0; i <= n / 3; i++) {
            if(arr[i]) {
                for(int k = 1; k <= n / 3; k++) {
                    int j = k;
                    while(true) {
                        int u = (i + j) % n;
                        if(!arr[u]) break;
                        if(i + j >= n) {
                            if(arr[u])
                                ret = true;
                            break out;
                        }
                        j += k;
                    }
                }
            }
        }
        if(ret) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        new CodeForce().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextLine() throws IOException {
        return reader.readLine();
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.io.*;
import java.util.*;

public class CodeForce {
    /*
    private static boolean can(int h, int w, int l, int []arr) {
        int area = h * w;
        for(int i = 0; i < arr.length; i++) {
            if(arr[i] < l) continue;
            else if(arr[i] >= w) {
                int d = arr[i] / w;
                area -= (d * w);
            } else if(w - arr[i] >= l) {
                area -= arr[i];
            }
        }
        return area <= 0;
    }

    private void solve() throws IOException {
        int n = nextInt(), l = nextInt();
        int []arr = new int[n];
        int m = Integer.MIN_VALUE;
        for(int i = 0; i < n; i++) {
            int u = nextInt();
            arr[i] = u;
            if(u > m) m = u;
        }

        int max = 0;
        for(int h = 1; h <= n; h++)
            for(int w = 1; w <= Math.max(n, m); w++)
                if(can(h, w, l, arr) && h * w > max)
                    max = h * w;
        System.out.println(max);
    }
    */

    private void solve() throws IOException {
        int n = nextInt();
        boolean []arr = new boolean[n];
        for(int i = 0; i < n; i++) {
            int u = nextInt();
            if(u == 1) arr[i] = true;
        }
        boolean ret = false;
        out:
        for(int i = 0; i <= n; i++) {
            if(arr[i]) {
                for(int k = 1; k <= n; k++) {
                    int j = k;
                    while(true) {
                        int u = (i + j) % n;
                        if(!arr[u]) break;
                        if(i + j >= n) {
                            if(arr[u])
                                ret = true;
                            break out;
                        }
                        j += k;
                    }
                }
            }
        }
        if(ret) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        new CodeForce().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextLine() throws IOException {
        return reader.readLine();
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.io.*;

import java.math.*;
import java.util.*;

import static java.lang.Math.*;

public class C65 {

	static InputStreamReader inp = new InputStreamReader(System.in);
	static BufferedReader in = new BufferedReader(inp);
	static boolean test = false;

	public String str() throws IOException {
		return in.readLine();
	}

	public static void main(String[] args) throws Throwable {
		if (test) {
			in = new BufferedReader(new FileReader(new File("testdata.txt")));
		}

		new C65().solve();
	}

	private int[] ints() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		int[] res = new int[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = Integer.parseInt(st.nextToken());
		}
		return res;
	}

	private long[] longs() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		long[] res = new long[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = Long.parseLong(st.nextToken());
		}
		return res;
	}

	private BigInteger[] bigs() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		BigInteger[] res = new BigInteger[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = new BigInteger(st.nextToken());
		}
		return res;
	}

	private int in() throws NumberFormatException, IOException {
		return Integer.parseInt(str());
	}

	private void solve() throws Throwable {
		int n = in();
		boolean[] siev = siev(n / 3);
		siev[1] = true;
		List<Integer> primesTmp = new ArrayList<Integer>();

		for (int i = 0; i < siev.length; i++) {
			if(siev[i]){
				primesTmp.add(i);
			}
		}

		List<Integer> primes = new ArrayList<Integer>();
		for (int i = 0; i < primesTmp.size(); i++) {
			int x = primesTmp.get(i);
			int tmp = primesTmp.get(i);
			while(x <= n / 3){
				x += tmp;
			}
			int val = x - tmp;
			primes.add(val);
		}
		int[] ints = ints();

		boolean works = false;

		for (int i = 0; i < primes.size() && !works; i++) {
			int step= primes.get(i);
			if(n % step != 0){
				continue;
			}

			out:for (int start = 0; start < step; start++) {
				for (int j = start; j < n; j += step) {
					if(ints[j] == 0){
						continue out;
					}
				}
				works = true;
			}
		}

		if(works){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

	private boolean[] siev(int n) {

		boolean[] prime = new boolean[n + 1];

		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;

		for (int i = 2; i < prime.length; i++) {
			int nr = i;
			if (prime[nr]) {
				nr += i;
				while (nr <= n) {
					prime[nr] = false;
					nr += i;
				}
			}
		}

		return prime;
	}
}


import java.io.*;

import java.math.*;
import java.util.*;

import static java.lang.Math.*;

public class C65 {

	static InputStreamReader inp = new InputStreamReader(System.in);
	static BufferedReader in = new BufferedReader(inp);
	static boolean test = false;

	public String str() throws IOException {
		return in.readLine();
	}

	public static void main(String[] args) throws Throwable {
		if (test) {
			in = new BufferedReader(new FileReader(new File("testdata.txt")));
		}

		new C65().solve();
	}

	private int[] ints() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		int[] res = new int[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = Integer.parseInt(st.nextToken());
		}
		return res;
	}

	private long[] longs() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		long[] res = new long[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = Long.parseLong(st.nextToken());
		}
		return res;
	}

	private BigInteger[] bigs() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		BigInteger[] res = new BigInteger[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = new BigInteger(st.nextToken());
		}
		return res;
	}

	private int in() throws NumberFormatException, IOException {
		return Integer.parseInt(str());
	}

	private void solve() throws Throwable {
		int n = in();
		boolean[] siev = siev(n / 3);
		siev[1] = true;
//		List<Integer> primesTmp = new ArrayList<Integer>();
//
//		for (int i = 0; i < siev.length; i++) {
//			if(siev[i]){
//				primesTmp.add(i);
//			}
//		}
//
//		List<Integer> primes = new ArrayList<Integer>();
//		for (int i = 0; i < primesTmp.size(); i++) {
//			int x = primesTmp.get(i);
//			int tmp = primesTmp.get(i);
//			while(x <= n / 3){
//				primes.add(x);
//				x += tmp;
//			}
//		}
		int[] ints = ints();

		boolean works = false;

		for (int i = 1; i <= n / 3 && !works; i++) {
			int step= i; // primes.get(i);
			if(n % step != 0){
				continue;
			}

			out:for (int start = 0; start < step; start++) {
				for (int j = start; j < n; j += step) {
					if(ints[j] == 0){
						continue out;
					}
				}
				System.out.println("YES");
				return;
//				works = true;
			}
		}

		System.out.println("NO");

	}

	private boolean[] siev(int n) {

		boolean[] prime = new boolean[n + 1];

		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;

		for (int i = 2; i < prime.length; i++) {
			int nr = i;
			if (prime[nr]) {
				nr += i;
				while (nr <= n) {
					prime[nr] = false;
					nr += i;
				}
			}
		}

		return prime;
	}
}


import java.io.*;

import java.math.*;
import java.util.*;

import static java.lang.Math.*;

public class C65 {

	static InputStreamReader inp = new InputStreamReader(System.in);
	static BufferedReader in = new BufferedReader(inp);
	static boolean test = false;

	public String str() throws IOException {
		return in.readLine();
	}

	public static void main(String[] args) throws Throwable {
		if (test) {
			in = new BufferedReader(new FileReader(new File("testdata.txt")));
		}

		new C65().solve();
	}

	private int[] ints() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		int[] res = new int[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = Integer.parseInt(st.nextToken());
		}
		return res;
	}

	private long[] longs() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		long[] res = new long[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = Long.parseLong(st.nextToken());
		}
		return res;
	}

	private BigInteger[] bigs() throws Throwable {
		StringTokenizer st = new StringTokenizer(str());

		BigInteger[] res = new BigInteger[st.countTokens()];
		for (int i = 0; i < res.length; i++) {
			res[i] = new BigInteger(st.nextToken());
		}
		return res;
	}

	private int in() throws NumberFormatException, IOException {
		return Integer.parseInt(str());
	}

	private void solve() throws Throwable {
		int n = in();
		boolean[] siev = siev(n / 3);
		siev[1] = true;
		List<Integer> primes = new ArrayList<Integer>();

		for (int i = 0; i < siev.length; i++) {
			if(siev[i]){
				primes.add(i);
			}
		}

		int[] ints = ints();

		boolean works = false;

		for (int i = 0; i < primes.size() && !works; i++) {
			int step= primes.get(i);
			if(n % step != 0){
				continue;
			}

			out:for (int start = 0; start < step; start++) {
				for (int j = start; j < n; j += step) {
					if(ints[j] == 0){
						continue out;
					}
				}
				works = true;
			}
		}

		if(works){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

	private boolean[] siev(int n) {

		boolean[] prime = new boolean[n + 1];

		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;

		for (int i = 2; i < prime.length; i++) {
			int nr = i;
			if (prime[nr]) {
				nr += i;
				while (nr <= n) {
					prime[nr] = false;
					nr += i;
				}
			}
		}

		return prime;
	}
}


import java.io.*;
import java.util.*;

/**
 * @author Artem Bochkarev
 *
 */
public class A implements Runnable {

	boolean isGood(int[] mood, int n) {
		boolean good = false;
		for (int start=0; start<n; ++start) {
			int i=start;
			boolean bad = false;
			while (i < mood.length) {
				if (mood[i] == 0) {
					bad = true;
					break;
				}
				i += n;
			}
			if (bad == false) {
				good = true;
				break;
			}
		}
		return good;
	}

	public void solve() throws IOException {
		int n = nextInt();
		int mood[] = new int[n];
		boolean tryIt[] = new boolean[n+10];
		for (int i=0; i<n; ++i) {
			mood[i] = nextInt();
			tryIt[i] = true;
		}
		tryIt[n] = true;
		boolean good =false;
		long K = Math.round(Math.sqrt(n))+1;
		for (int i=3; i<=n; ++i) {
			if ((n%i == 0)&&(tryIt[i] == true)) {
				if (isGood(mood, n/i)) {
					good = true;
					break;
				}else {
					for (int j=i; j<K; j+=i) {
						tryIt[j] = false;
					}
				}
			}
		}
		if (good) {
			out.println("YES");
		}else {
			out.println("NO");
		}
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;

	String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(br.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	String nextStr() throws IOException {
		return nextToken();
	}

	char nextChar() throws IOException {
		return nextToken().charAt(0);
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			st = new StringTokenizer("");
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		new Thread(new A()).start();
	}
}


//package round65;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C {

	static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;
	static PrintWriter out = new PrintWriter(System.out);

	static String nextToken() throws IOException{
		while (st==null || !st.hasMoreTokens()){
			String s = bf.readLine();
			if (s == null)
				return null;
			st = new StringTokenizer(s);
		}

		return st.nextToken();
	}

	static int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}

	static String nextStr() throws IOException{
		return nextToken();
	}

	static double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}

	static boolean prime(int n){
		for (int i=2; i*i<=n; i++)
			if (n%i == 0)
				return false;
		return true;
	}

	public static void main(String[] args) throws IOException{
		int n = nextInt();
		int s[] = new int[n];
		for (int i=0; i<n; i++)
			s[i] = nextInt();

		for (int i=3; i<=n; i++)
			if (n%i==0){
				int p = n/i;
				int a[] = new int[p];

				for (int j=0; j<s.length; j++)
					if (s[j] == 1)
						a[j%p]++;

				for (int j=0; j<p; j++)
					if (a[j] == i){
						out.println("YES");
						out.flush();
						return;
					}
			}

		out.println("NO");
		out.flush();

	}

}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class ProblemC_65 {

    final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok=new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in=new BufferedReader(new InputStreamReader(System.in));
            out =new PrintWriter(System.out);
        }
        else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            tok=new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    public static void main(String[] args){
        new ProblemC_65().run();
    }

    public void run(){
        try{
            long t1=System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2=System.currentTimeMillis();
            System.err.println("Time = "+(t2-t1));
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    void solve() throws IOException{
        int n = readInt();
        boolean[] b = new boolean[n];
        for (int i = 0; i < n; i++){
            b[i] = readInt() == 1;
        }
        int[] p = Sieve(n);
        p[0] = 3;
        p[1] = 4;
        for (int i = 0; i < p.length; i++){
            if (n % p[i] == 0){
            a:  for (int j = 0; j < p[i] - 1; j++){
                    for (int k = j; k < n; k += n/p[i]){
                        if (!b[k]){
                            continue a;
                        }
                    }
                    out.print("YES");
                    return;
                }
            }
        }
        out.print("NO");
    }

    int[] Sieve(int n){
        boolean[] b = new boolean[n+1];
        Arrays.fill(b, true);
        b[0] = false;
        b[1] = false;
        long nLong = n;
        int j=0;
        for (int i = 1; i <= n; i++) {
            if (b[i]){
                j++;
                if (((long)i)*i <= nLong) {
                    for (int k = i*i; k <= n; k += i) {
                        b[k] = false;
                    }
                }
            }
        }
        int[] p = new int[j];
        Arrays.fill(p, 0);
        j=0;
        for (int i = 2; i <= n; i++) {
            if (b[i]){
                p[j]=i;
                j++;
            }
        }
        return p;
    }
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class ProblemC_65 {

    final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok=new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in=new BufferedReader(new InputStreamReader(System.in));
            out =new PrintWriter(System.out);
        }
        else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            tok=new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    public static void main(String[] args){
        new ProblemC_65().run();
    }

    public void run(){
        try{
            long t1=System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2=System.currentTimeMillis();
            System.err.println("Time = "+(t2-t1));
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    void solve() throws IOException{
        int n = readInt();
        boolean[] b = new boolean[n];
        for (int i = 0; i < n; i++){
            b[i] = readInt() == 1;
        }
        int[] p = Sieve(n);
        p[0] = 3;
        p[1] = 4;
        for (int i = 0; i < p.length; i++){
            if (n % p[i] == 0){
            a:  for (int j = 0; j < p[i] - 1; j++){
                    for (int k = j; k < n + j; k += n/p[i]){
                        if (!b[k % n]){
                            continue a;
                        }
                    }
                    out.print("YES");
                    return;
                }
            }
        }
        out.print("NO");
    }

    int[] Sieve(int n){
        boolean[] b = new boolean[n+1];
        Arrays.fill(b, true);
        b[0] = false;
        b[1] = false;
        long nLong = n;
        int j=0;
        for (int i = 1; i <= n; i++) {
            if (b[i]){
                j++;
                if (((long)i)*i <= nLong) {
                    for (int k = i*i; k <= n; k += i) {
                        b[k] = false;
                    }
                }
            }
        }
        int[] p = new int[j];
        Arrays.fill(p, 0);
        j=0;
        for (int i = 2; i <= n; i++) {
            if (b[i]){
                p[j]=i;
                j++;
            }
        }
        return p;
    }
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class ProblemC_65 {

    final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok=new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in=new BufferedReader(new InputStreamReader(System.in));
            out =new PrintWriter(System.out);
        }
        else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            tok=new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    public static void main(String[] args){
        new ProblemC_65().run();
    }

    public void run(){
        try{
            long t1=System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2=System.currentTimeMillis();
            System.err.println("Time = "+(t2-t1));
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    void solve() throws IOException{
        int n = readInt();
        boolean[] b = new boolean[n];
        for (int i = 0; i < n; i++){
            b[i] = readInt() == 1;
        }
        int[] p = Sieve(n);
        p[0] = 3;
        p[1] = 4;
        for (int i = 0; i < p.length; i++){
            if (n % p[i] == 0){
            a:  for (int j = 0; j < n/p[i]; j++){
                    for (int k = j; k < n + j; k += n/p[i]){
                        if (!b[k % n]){
                            continue a;
                        }
                    }
                    out.print("YES");
                    return;
                }
            }
        }
        out.print("NO");
    }

    int[] Sieve(int n){
        boolean[] b = new boolean[n+1];
        Arrays.fill(b, true);
        b[0] = false;
        b[1] = false;
        long nLong = n;
        int j=0;
        for (int i = 1; i <= n; i++) {
            if (b[i]){
                j++;
                if (((long)i)*i <= nLong) {
                    for (int k = i*i; k <= n; k += i) {
                        b[k] = false;
                    }
                }
            }
        }
        int[] p = new int[j];
        Arrays.fill(p, 0);
        j=0;
        for (int i = 2; i <= n; i++) {
            if (b[i]){
                p[j]=i;
                j++;
            }
        }
        return p;
    }
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class ProblemC_65 {

    final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok=new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in=new BufferedReader(new InputStreamReader(System.in));
            out =new PrintWriter(System.out);
        }
        else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            tok=new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    public static void main(String[] args){
        new ProblemC_65().run();
    }

    public void run(){
        try{
            long t1=System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2=System.currentTimeMillis();
            System.err.println("Time = "+(t2-t1));
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    void solve() throws IOException{
        int n = readInt();
        boolean[] b = new boolean[n];
        for (int i = 0; i < n; i++){
            b[i] = readInt() == 1;
        }
        int[] p = Sieve(n);
        p[0] = 3;
        p[1] = 4;
        for (int i = 0; i < p.length; i++){
            if (n % p[i] == 0){
            a:  for (int j = 0; j < 1/*p[i] - 1*/; j++){
                    for (int k = j; k < n + j; k += n/p[i]){
                        if (!b[k % n]){
                            continue a;
                        }
                    }
                    out.print("YES");
                    return;
                }
            }
        }
        out.print("NO");
    }

    int[] Sieve(int n){
        boolean[] b = new boolean[n+1];
        Arrays.fill(b, true);
        b[0] = false;
        b[1] = false;
        long nLong = n;
        int j=0;
        for (int i = 1; i <= n; i++) {
            if (b[i]){
                j++;
                if (((long)i)*i <= nLong) {
                    for (int k = i*i; k <= n; k += i) {
                        b[k] = false;
                    }
                }
            }
        }
        int[] p = new int[j];
        Arrays.fill(p, 0);
        j=0;
        for (int i = 2; i <= n; i++) {
            if (b[i]){
                p[j]=i;
                j++;
            }
        }
        return p;
    }
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class ProblemC_65 {

    final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok=new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in=new BufferedReader(new InputStreamReader(System.in));
            out =new PrintWriter(System.out);
        }
        else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            tok=new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    public static void main(String[] args){
        new ProblemC_65().run();
    }

    public void run(){
        try{
            long t1=System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2=System.currentTimeMillis();
            System.err.println("Time = "+(t2-t1));
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    void solve() throws IOException{
        int n = readInt();
        boolean[] b = new boolean[n];
        for (int i = 0; i < n; i++){
            b[i] = readInt() == 1;
        }
        int[] p = Sieve(n);
        p[0] = 3;
        p[1] = 4;
        for (int i = 0; i < p.length; i++){
            if (n % p[i] == 0){
            a:  for (int j = 0; j < p[i]; j++){
                    for (int k = j; k < n + j; k += n/p[i]){
                        if (!b[k % n]){
                            continue a;
                        }
                    }
                    out.print("YES");
                    return;
                }
            }
        }
        out.print("NO");
    }

    int[] Sieve(int n){
        boolean[] b = new boolean[n+1];
        Arrays.fill(b, true);
        b[0] = false;
        b[1] = false;
        long nLong = n;
        int j=0;
        for (int i = 1; i <= n; i++) {
            if (b[i]){
                j++;
                if (((long)i)*i <= nLong) {
                    for (int k = i*i; k <= n; k += i) {
                        b[k] = false;
                    }
                }
            }
        }
        int[] p = new int[j];
        Arrays.fill(p, 0);
        j=0;
        for (int i = 2; i <= n; i++) {
            if (b[i]){
                p[j]=i;
                j++;
            }
        }
        return p;
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;

public class Solution71C {

        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");

        void init() throws FileNotFoundException{
                if (ONLINE_JUDGE){
                        in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
                }else{
                        in = new BufferedReader(new FileReader("input.txt"));
                        out = new PrintWriter("output.txt");
                }
        }

        String readString() throws IOException{
                while(!tok.hasMoreTokens()){
                        tok = new StringTokenizer(in.readLine());
                }
                return tok.nextToken();
        }

        int readInt() throws IOException{
                return Integer.parseInt(readString());
        }

        long readLong() throws IOException{
                return Long.parseLong(readString());
        }

        double readDouble() throws IOException{
                return Double.parseDouble(readString());
        }

        public static void main(String[] args){
                new Solution71C().run();
        }

        public void run(){
                try{
                        long t1 = System.currentTimeMillis();
                        init();
                        solve();
                        out.close();
                        long t2 = System.currentTimeMillis();
                        System.err.println("Time = "+(t2-t1));
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }

        static class Utils {

                private Utils() {}

                public static void mergeSort(int[] a) {
                        mergeSort(a, 0, a.length - 1);
                }

                private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
                        final int MAGIC_VALUE = 50;
                        if (leftIndex < rightIndex) {
                                if (rightIndex - leftIndex <= MAGIC_VALUE) {
                                        insertionSort(a, leftIndex, rightIndex);
                                } else {
                                        int middleIndex = (leftIndex + rightIndex) / 2;
                                        mergeSort(a, leftIndex, middleIndex);
                                        mergeSort(a, middleIndex + 1, rightIndex);
                                        merge(a, leftIndex, middleIndex, rightIndex);
                                }
                        }
                }

                private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
                        int length1 = middleIndex - leftIndex + 1;
                        int length2 = rightIndex - middleIndex;
                        int[] leftArray = new int[length1];
                        int[] rightArray = new int[length2];
                        System.arraycopy(a, leftIndex, leftArray, 0, length1);
                        System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
                        for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
                                if (i == length1) {
                                        a[k] = rightArray[j++];
                                } else if (j == length2) {
                                        a[k] = leftArray[i++];
                                } else {
                                        a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
                                }
                        }
                }

                private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
                        for (int i = leftIndex + 1; i <= rightIndex; i++) {
                                int current = a[i];
                                int j = i - 1;
                                while (j >= leftIndex && a[j] > current) {
                                        a[j + 1] = a[j];
                                        j--;
                                }
                                a[j + 1] = current;
                        }
                }
        }

        void solve() throws IOException{
        	int n = readInt();
        	int[] a = new int[n];
        	for(int i = 0; i < n; i++)
        		a[i] = readInt();
        	int max = n / 3;
        	for(int i = 1; i <= max; i++){
        		if(n % i == 0){
        			for(int j = 0; j < i; j++){
        				boolean check = true;
        				for(int k = j; k < n; k += i)
        					if(a[k] == 0) check = false;
        				if(check){
        					out.println("YES");
        					return;
        				}
        			}
        		}
        	}
        	out.println("NO");
        }

        static double distance(long x1, long y1, long x2, long y2){
        	return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        }

        static long gcd(long a, long b){
        	while(a != b){
        		if(a < b) a -=b;
        		else b -= a;
        	}
        	return a;
        }

        static long lcm(long a, long b){
        	return a * b /gcd(a, b);
        }
}


import java.io.*;

/**
 * Codeforces Beta Round #65 (Div. 2), C
 * @author Roman Kosenko <madkite@gmail.com>
 */
public class RoundTableKnights {
	public static void main(String[] args) throws IOException {
		if(!Boolean.parseBoolean(System.getProperty("ONLINE_JUDGE")))
			System.setIn(new FileInputStream(new File("input.txt")));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String s = br.readLine();
		boolean a[] = new boolean[n];
		for(int i = 0; i < n; i++)
			a[i] = s.charAt(i * 2) == '1';
		System.out.println(solve(a) ? "YES" : "NO");
	}
	private static boolean solve(boolean a[]) {
		boolean b[] = new boolean[a.length];
		for(int n = a.length, i = n / 3; i > 0; i--) {
			if(n % i != 0 || b[i])
				continue;
			for(int s = 0; s < i; s++) {
				boolean result = true;
				for(int j = s, k = n / i; result && k > 0; k--, j += i)
					result = a[j % n];
				if(result)
					return true;
			}
			for(int j = 2, z = i; j <= z && !b[z]; j++) {
				if(z % j == 0) {
					b[z] = b[j] = true;
					do
						z /= j;
					while(z % j == 0);
				}
			}
		}
		return false;
	}
}


import java.io.*;

/**
 * Codeforces Beta Round #65 (Div. 2), C
 * @author Roman Kosenko <madkite@gmail.com>
 */
public class RoundTableKnights {
	public static void main(String[] args) throws IOException {
		if(!Boolean.parseBoolean(System.getProperty("ONLINE_JUDGE")))
			System.setIn(new FileInputStream(new File("input.txt")));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String s = br.readLine();
		boolean a[] = new boolean[n];
		for(int i = 0; i < n; i++)
			a[i] = s.charAt(i * 2) == '1';
		System.out.println(solve(a) ? "YES" : "NO");
	}
	private static boolean solve(boolean a[]) {
		for(int n = a.length, i = n / 3; i > 0; i--) {
			if(n % i != 0)
				continue;
			for(int s = 0; s < i; s++) {
				boolean result = true;
				for(int j = s, k = n / i; result && k > 0; k--, j += i)
					result = a[j % n];
				if(result)
					return true;
			}
		}
		return false;
	}
}


import java.io.*;

/**
 * Codeforces Beta Round #65 (Div. 2), C
 * @author Roman Kosenko <madkite@gmail.com>
 */
public class RoundTableKnights {
	public static void main(String[] args) throws IOException {
		if(!Boolean.parseBoolean(System.getProperty("ONLINE_JUDGE")))
			System.setIn(new FileInputStream(new File("input.txt")));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String s = br.readLine();
		boolean a[] = new boolean[n];
		for(int i = 0; i < n; i++)
			a[i] = s.charAt(i * 2) == '1';
		System.out.println(solve(a) ? "YES" : "NO");
	}
	private static boolean solve(boolean a[]) {
		boolean b[] = new boolean[a.length];
		for(int n = a.length, i = n / 3; i > 0; i--) {
			if(n % i != 0 || b[i])
				continue;
			for(int s = 0; s < i; s++) {
				boolean result = true;
				for(int j = s, k = n / i; result && k > 0; k--, j += i)
					result = a[j % n];
				if(result)
					return true;
			}
			for(int j = 2, z = i; j <= z && !b[z]; j++) {
				if(z % j == 0) {
					b[z] = b[j] = true;
					do
						z /= j;
					while(z % j == 0);
				}
			}
			b[1] = true;
		}
		return false;
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {

	void solve() throws IOException {
		int n = nextInt();
		boolean[] x = new boolean[n * 2];
		int[] a = new int[n * 2];

		for (int i = 0; i < n; i++) {
			x[i] = nextInt() == 1;
			x[n + i] = x[i];
		}

		for (int i = 3; i <= n; i++) {
			if (n % i == 0) {
				final int step = n / i;
				Arrays.fill(a, 0);
				for (int j = step; j < 2 * n; j++) {
					if (x[j]) {
						a[j] = a[j - step] + 1;
						if (a[j] == i) {
							out.println("YES");
							return;
						}
					}
				}
			}
		}

		out.println("NO");
	}

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	Main() throws IOException {
		Locale.setDefault(Locale.ENGLISH);
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		eat("");
		solve();
		in.close();
		out.close();
	}

	private void eat(String str) {
		st = new StringTokenizer(str);
	}

	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;

/**
 * Created by IntelliJ IDEA.
 * User: piyushd
 * Date: 3/18/11
 * Time: 9:28 PM
 * To change this template use File | Settings | File Templates.
 */
public class TaskC {

    void run(){
        int n = nextInt();
        int[] a = new int[n];

        ArrayList<Integer> bad = new ArrayList<Integer>();
        for(int i = 0; i < n; i++){
            a[i] = nextInt();
            if(a[i] == 0) bad.add(i);
        }

        ArrayList<Integer> factors = new ArrayList<Integer>();
        for(int i = 1; i <= (n / 3); i++)
            if(n % i == 0) factors.add(i);
        Integer[] f = new Integer[factors.size()];
        factors.toArray(f);

        HashSet<Integer> set = new HashSet<Integer>();
        int low = 0, high = f.length;
        boolean got = false;
        while(high - low >= 1){
            int mid = low + (high - low) / 2;
            int fac = f[mid];

            set.clear();
            for(int x : bad) set.add(x % fac);
            if(set.size() < fac){
                got = true; break;
            }

            low = mid + 1;
        }

        if (got) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    int nextInt(){
        try{
            int c = System.in.read();
            if(c == -1) return c;
            while(c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c == -1) return c;
            }
            if(c == '-') return -nextInt();
            int res = 0;
            do{
                res *= 10;
                res += c - '0';
                c = System.in.read();
            }while('0' <= c && c <= '9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

    long nextLong(){
        try{
            int c = System.in.read();
            if(c == -1) return -1;
            while(c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c == -1) return -1;
            }
            if(c == '-') return -nextLong();
            long res = 0;
            do{
                res *= 10;
                res += c-'0';
                c = System.in.read();
            }while('0' <= c && c <= '9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

    double nextDouble(){
        return Double.parseDouble(next());
    }

    String next(){
        try{
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while(Character.isWhitespace(c))
                c = System.in.read();
            do{
                res.append((char)c);
            }while(!Character.isWhitespace(c=System.in.read()));
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

    String nextLine(){
        try{
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while(c == '\r' || c == '\n')
                c = System.in.read();
            do{
                res.append((char)c);
                c = System.in.read();
            }while(c != '\r' && c != '\n');
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

    public static void main(String[] args){
        new TaskC().run();
    }
}


import java.util.*;
import java.io.*;

import static java.lang.Math.*;

public class Main {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    int n;
    int[] v;

    ArrayList<Integer> divisors(int n) {
        ArrayList<Integer> ret = new ArrayList<Integer>();
        for (int i = 1; i * i <= n; ++i) {
            if (n % i == 0) {
                ret.add(i);
                if (n / i != i)
                    ret.add(n / i);
            }
        }
        Collections.sort(ret);
        return ret;
    }

    boolean check(int divisor) {
        if (n / divisor < 3)
            return false;
        int index = 0;
        while (index < n) {
            if (index >= divisor)
                break;
            boolean found = true;
            for (int i = index; i < n; i += divisor)
                if (v[i] == 0) {
                    found = false;
                    break;
                }
            if (found)
                return true;
            ++index;
        }
        return false;
    }

    void solve() throws IOException {
        n = ni();
        v = new int[n];
        for (int i = 0; i < n; ++i)
            v[i] = ni();
        ArrayList<Integer> l = divisors(n);
        for (int divisor : l) {
            if (check(divisor)) {
                out.println("YES");
                return;
            }
        }
        out.println("NO");
    }

    void test() throws FileNotFoundException {
        PrintWriter out = new PrintWriter("test");
        out.println("100000");
        for (int i = 0; i < 100000; ++i)
            out.println(new Random().nextInt(2));
        out.close();
    }

    public Main() throws IOException {
        // test();
        in = new BufferedReader(new InputStreamReader(System.in));
        // in = new BufferedReader(new FileReader("test"));
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    String ns() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int ni() throws IOException {
        return Integer.valueOf(ns());
    }

    long nl() throws IOException {
        return Long.valueOf(ns());
    }

    double nd() throws IOException {
        return Double.valueOf(ns());
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}