Problem: Input Format

The input format is following:



n m q
a_1 a_2 ... a_q


Output Format

Print the number of connected part in one line.


Constraints

* n ≤ 10^{12}
* 7n is divisible by m.
* 1 ≤ q ≤ m ≤ 10^5
* 0 ≤ a_1 < a_2 < ... < a_q < m



Scoring

Subtask 1 [100 points]


* n ≤ 100000.

Subtask 2 [90 points]


* m is divisible by 7.
* a_{i + 1} - a_i = 1.

Subtask 3 [200 points]


* m is divisible by 7.

Subtask 4 [110 points]


* There are no additional constraints.



Sample Input 1


7 7 3
1 3 5


Sample Output 1


4


The calendar looks like this:


<image>

Sample Input 2


10 14 8
5 6 7 8 9 10 11 12


Sample Output 2


10


The calendar looks like this:


<image>

Output Format

Print the number of connected part in one line.


Constraints

* n ≤ 10^{12}
* 7n is divisible by m.
* 1 ≤ q ≤ m ≤ 10^5
* 0 ≤ a_1 < a_2 < ... < a_q < m



Scoring

Subtask 1 [100 points]


* n ≤ 100000.

Subtask 2 [90 points]


* m is divisible by 7.
* a_{i + 1} - a_i = 1.

Subtask 3 [200 points]


* m is divisible by 7.

Subtask 4 [110 points]


* There are no additional constraints.

Input Format

The input format is following:



n m q
a_1 a_2 ... a_q

Examples

Input

7 7 3
1 3 5


Output

4


Input

10 14 8
5 6 7 8 9 10 11 12


Output

10

Solution (in CPP):

Solution:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class UnionFindTree
{
private:
    const int n;
    int groupNum;       // グループの数
    vector<int> parent; // 親ノード
    vector<int> rank;   // 木の高さの上限
    vector<int> num;    // グループの要素数
    int find(int i){
        if(parent[i] == i)
            return i;
        else
            return parent[i] = find(parent[i]);
    }
public:
    UnionFindTree(int n) : n(n){ // コンストラクタ
        groupNum = n;
        parent.resize(n);
        for(int i=0; i<n; ++i)
            parent[i] = i;
        rank.assign(n, 0);
        num.assign(n, 1);
    }
    void unite(int a, int b){ // aとbのグループを併合
        if((a = find(a)) != (b = find(b))){
            if(rank[a] < rank[b]){
                parent[a] = b;
                num[b] += num[a];
            }
            else{
                parent[b] = a;
                if(rank[a] == rank[b])
                    ++ rank[a];
                num[a] += num[b];
            }
            -- groupNum;
        }
    }
    bool same(int a, int b){ // aとbのグループが同じかを調べる
        return find(a) == find(b);
    }
    int getNum(){ // グループの数を返す
        return groupNum;
    }
    int getNum(int a){ // aのグループの要素数を返す
        return num[find(a)];
    }
    void getGroup(vector<vector<int> >& group){ // グループ構成を返す
        map<int, int> index;
        group.clear();
        for(int i=0; i<n; ++i){
            int a = find(i);
            if(index.find(a) == index.end()){
                index[a] = group.size();
                group.resize(group.size() + 1);
            }
            group[index[a]].push_back(i);
        }
    }
};

const int dy[] = {-1, 0, 0, 1};
const int dx[] = {0, 1, -1, 0};

int main()
{
    long long n;
    int m, q;
    cin >> n >> m >> q;
    vector<bool> rest(m, false);
    for(int i=0; i<q; ++i){
        int a;
        cin >> a;
        rest[a] = true;
    }

    int len = m;
    if(len % 7 != 0)
        len *= 7;

    vector<bool> black(2*len);
    for(int i=0; i<2*len; ++i){
        if(rest[i%m])
            black[i] = true;
    }

    UnionFindTree uft(2*len+1);
    int invalid = 2 * len;
    for(int i=0; i<len; ++i){
        int y = i / 7;
        int x = i % 7;
        if(black[i]){
            uft.unite(i, invalid);
        }
        else{
            for(int j=0; j<4; ++j){
                int y2 = y + dy[j];
                int x2 = x + dx[j];
                if(!(0 <= y2 && y2 < len/7 && 0 <= x2 && x2 < 7))
                    continue;
                int k = y2 * 7 + x2;
                if(!black[k])
                    uft.unite(i, k);
            }
        }
    }
    int cnt1 = uft.getNum() - len - 1;

    for(int i=len; i<2*len; ++i){
        int y = i / 7;
        int x = i % 7;
        if(black[i]){
            uft.unite(i, invalid);
        }
        else{
            for(int j=0; j<4; ++j){
                int y2 = y + dy[j];
                int x2 = x + dx[j];
                if(!(0 <= y2 && y2 < 2*len/7 && 0 <= x2 && x2 < 7))
                    continue;
                int k = y2 * 7 + x2;
                if(!black[k])
                    uft.unite(i, k);
            }
        }
    }
    int cnt2 = uft.getNum() - cnt1 - 1;

    long long ans = cnt1;
    ans += (7 * n - len) / len * cnt2;
    cout << ans << endl;

    return 0;
}