func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 50010;   const int inf = 1e9;   inline int read() {     int p = 0;     int f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       p = p * 10 + ch -  0 ;       ch = getchar();     }     return p * f;   }   struct node {     int x, y, d, c, next;   } edge[N << 4];   int len, first[N];   void ins(int x, int y, int c, int d) {     len++;     edge[len].x = x;     edge[len].y = y;     edge[len].c = c;     edge[len].d = d;     edge[len].next = first[x];     first[x] = len;     len++;     edge[len].x = y;     edge[len].y = x;     edge[len].c = 0;     edge[len].d = -d;     edge[len].next = first[y];     first[y] = len;   }   bool v[N];   int d[N];   queue<int> q;   int pre[N], pos[N];   int s, t;   bool bfs() {     while (!q.empty()) q.pop();     q.push(s);     memset(d, -63, sizeof(d));     d[s] = 0;     memset(v, 0, sizeof(v));     v[s] = 1;     while (!q.empty()) {       int x = q.front();       for (int k = first[x]; k != -1; k = edge[k].next) {         int y = edge[k].y;         if (d[y] < d[x] + edge[k].d && edge[k].c) {           d[y] = d[x] + edge[k].d;           pos[y] = x;           pre[y] = k;           if (!v[y]) {             v[y] = 1;             q.push(y);           }         }       }       q.pop();       v[x] = 0;     }     return d[t] >= 0;   }   int n, a[N];   int main() {     len = 1;     memset(first, -1, sizeof(first));     n = read();     for (int i = 1; i <= n; i++) a[i] = read();     int ss = 2 * n + 1;     s = ss + 1;     t = s + 1;     ins(s, ss, 4, 0);     for (int i = 1; i <= n; i++) {       ins(ss, i + n, 1, 0);       ins(i + n, i, 1, 1);       ins(i, t, 1, 0);     }     for (int i = 1; i <= n; i++) {       int cnt = 0;       for (int j = i + 1; j <= n; j++)         if ((a[i] - a[j] == 1) && cnt < 1) {           ins(i, j + n, inf, 0);           cnt++;         }       cnt = 0;       for (int j = i + 1; j <= n; j++)         if ((a[i] - a[j] == -1) && cnt < 1) {           ins(i, j + n, inf, 0);           cnt++;         }       cnt = 0;       for (int j = i + 1; j <= n; j++)         if ((a[i] % 7 == a[j] % 7) && cnt < 1) {           ins(i, j + n, inf, 0);           cnt++;         }       ins(i + n, i, inf, 0);     }     int ans = 0;     while (bfs()) {       for (int i = t; i != s; i = pos[i])         ans += edge[pre[i]].d, edge[pre[i]].c--, edge[pre[i] ^ 1].c++;     }     return printf( %d n , ans), 0;   }   