Under construction

Still being built. Things may change

Grandpa Pepe's Pizza

Interview

Time limit2sMemory limit512 MB

Summary
Given N olive positions on a circle of circumference C, decide whether equal sectors of length C/N can each contain exactly one olive.
Level

Medium5 of 10

Topics
Math, Implementation, Sorting
Solved
No attempts yet

Problem

Grandpa Pepe's pizzas are perfect circles. Tonight's pizza has a few olives sitting exactly on the rim, at arbitrary positions.

You are given the circumference CC of the pizza, the number of olives NN, and the position of every olive. Decide whether the pizza can be cut into circular sectors of equal size so that every slice holds exactly one olive.

One slice holds exactly one olive, so the number of slices is NN and each slice covers an arc of length C/NC/N. Every cut is a radius from the center to the rim, and a cut can be made at any point of the circumference, not only at an integer position. No olive may lie on a cut. The olives are tiny, so their size is ignored.

The figure below shows (a) a pizza of circumference 1212 with three olives and one way to split it into equal slices, and (b) a pizza of circumference 1212 with four olives that cannot be split this way.

Input

The first line contains two integers CC and NN (3≤C≤1000003 \le C \le 100000, 3≤N≤100003 \le N \le 10000, N≤CN \le C). CC is a multiple of NN.

The second line contains NN distinct integers X1,X2,…,XNX_1, X_2, \dots, X_N in increasing order (0≤X1<X2<⋯<XN<C0 \le X_1 < X_2 < \dots < X_N < C), the positions of the olives. A position is the arc length measured clockwise from a fixed point of the circumference.

Output

Print one line holding a single letter. Print S if the pizza can be cut as described, and N otherwise.

Examples2

  1. Example 1

    Input
    12 3
    2 8 11
    
    Expected output
    S
    
  2. Example 2

    Input
    12 4
    4 5 7 11
    
    Expected output
    N