#include<bits/stdc++.h>
#define ll long long
#define MAX 1000003
#define V vector<int>
#define pii pair<int,int>
#define VP vector< pii >
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define SL(x) scanf("%lld",&(x))
#define SL2(x) scanf("%lld%lld",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define FF first
#define SS second
using namespace std;

int main(){
 int n,k1,k2;
 cin>>n;
 k1 = 1, k2 = (n-1)/2;
 rep(i,0,(n-1)/2){
 	rep(j,0,k2){
 		cout<< "*";
 	}
 	rep(k,0,k1){
 		cout<< "D";
 	}
 	rep(l,0,k2){
 		cout<< "*";
 	}
   k1+=2;
   k2-=1;
   cout<< endl;
 }

 rep(i,0,n){
 	cout<< "D";
 }
 cout<< endl;

 rep(i,0,(n-1)/2){
   k1-=2;
   k2+=1;
 	rep(j,0,k2){
 		cout<< "*";
 	}
 	rep(k,0,k1){
 		cout<< "D";
 	}
 	rep(l,0,k2){
 		cout<< "*";
 	}

   cout<< endl;
 }

}

/*
Code by :
Rishabh Patel
Integrated Post Graduation (IPG)
Indian Institute of Information Technology and Management, Gwalior (ABV-IIITM Gwalior)
In order to understand recursion, one must first understand recursion.
*/


#include<bits/stdc++.h>
#define ll long long
#define MAX 1000003
#define V vector<int>
#define pii pair<int,int>
#define VP vector< pii >
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define SL(x) scanf("%lld",&(x))
#define SL2(x) scanf("%lld%lld",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define FF first
#define SS second
using namespace std;

int main(){
 int n,k1,k2;
 cin>>n;
 k1 = 1, k2 = (n-1)/2;
 rep(i,0,(n-1)/2){
 	rep(j,0,k2){
 		cout<< "*";
 	}
 	rep(k,0,k1){
 		cout<< "d";
 	}
 	rep(l,0,k2){
 		cout<< "*";
 	}
   k1+=2;
   k2-=1;
   cout<< endl;
 }

 rep(i,0,n){
 	cout<< "d";
 }
 cout<< endl;

 rep(i,0,(n-1)/2){
   k1-=2;
   k2+=1;
 	rep(j,0,k2){
 		cout<< "*";
 	}
 	rep(k,0,k1){
 		cout<< "D";
 	}
 	rep(l,0,k2){
 		cout<< "*";
 	}

   cout<< endl;
 }

}

/*
Code by :
Rishabh Patel
Integrated Post Graduation (IPG)
Indian Institute of Information Technology and Management, Gwalior (ABV-IIITM Gwalior)
In order to understand recursion, one must first understand recursion.
*/


#include<bits/stdc++.h>
using namespace std;
int main ()
{
  int a;
  cin>>a;
  for(int i = 0; i<a; i++)
  {
    for(int j = 0; i<a; j++)
    {
      if(abs(i-a/2)+abs(j-a/2)<=a/2)
        cout<<"D";
      else
        cout<<'*';
    }
    cout<<endl;
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main ()
{
  int a;
  cin>>a;
  for(int i = 0; i<a; i++)
  {
    for(int j = 0; j<a; j++)
    {
      if(abs(i-a/2)+abs(j-a/2)<=a/2)
        cout<<"D";
      else
        cout<<'*';
    }
    cout<<endl;
  }
  return 0;
}


#include<iostream>
#include<cstdio>
#include<math.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<stack>
#include <vector>
#include<queue>
#include<map>
#include <sstream>
using namespace std ;
typedef long long ll ;
int main()
{
// freopen ("input.txt","r",stdin);
 int n ;
 scanf("%d" , &n);
 string str[101] ;
 int odd[110] = {} , j = 0 , stars[110] = {} ;
 for(int i = 1 ; j <= n ; i+=2)
 {
  odd[j] += i ;
  stars[j] += abs(n - odd[j]);
  ++j ;
  //cout << stars[j] << " "<<odd[j]<<endl;
 }
 bool flg = false ;
 int l ;
 for(int i = 0 ; i < n ;++i)
 {
  for(int k = 0 ; k < stars[i] / 2 ; ++k)
   cout << '*';

  if(odd[i] <= n){
 for(int d = 0 ; d < odd[i]; ++d){
  cout <<'D';
   l = i ;
}}
else {
  --l;
  for(int d=  0 ; d < odd[l]; ++d) cout <<"D";
}
for(int kk = 0 ; kk < stars[i]/2; ++kk)
   cout <<'*';
 cout << endl;
 }
  return 0 ;
}


#include<iostream>
#include<cstdio>
#include<math.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<stack>
#include <vector>
#include<queue>
#include<map>
#include <sstream>
using namespace std ;
typedef long long ll ;
int main()
{
// freopen ("input.txt","r",stdin);
 int n ;
 scanf("%d" , &n);
 string str[101] ;
 int odd[101] = {} , j = 0 , stars[101] = {} ;
 for(int i = 1 ; j <= n ; i+=2)
 {
  odd[j] += i ;
  stars[j] += abs(n - odd[j]);
  ++j ;
  //cout << stars[j] << " "<<odd[j]<<endl;
 }
 bool flg = false ;
 int l ;
 for(int i = 0 ; i < n ;++i)
 {
  for(int k = 0 ; k < stars[i] / 2 ; ++k)
   cout << '*';

  if(odd[i] <= n){
 for(int d = 0 ; d < odd[i]; ++d){
  cout <<'D';
   l = i ;
}}
else {
  --l;
  for(int d=  0 ; d < odd[l]; ++d) cout <<"D";
}
for(int kk = 0 ; kk < stars[i]/2; ++kk)
   cout <<'*';
 cout << endl;
 }
  return 0 ;
}


#include<iostream>

using namespace std;

int main()
{
int i,j=1,n;
cin>>n;

for(i=0;i<n;i++)
{j=0;
while(j<n&&i<=n/2)
{
if(j<=n/2+i&&j>=n/2-i)
cout<<"D";

else
cout<<"*";

j++;

}

while(j<n&&i>n/2)
{
if(j<=n/2+n-i-1&&j>=n/2-n+i+1)
cout<<"D";

else
cout<<"*";

j++;

}

cout<<endl;
}

return 0;
}


#include<iostream>

using namespace std;

int main()
{
int i,j=1,n;
cin>>n;

for(i=0;i<n;i++)
{
while(j<=n&&i<=n/2)
{
if(j<=n/2+i&&j>=n/2-i)
cout<<"D";

else
cout<<"*";

j++;

}

while(j<=n&&i>n/2)
{
if(j<=n/2+n-i-1&&j>=n/2-n+i+1)
cout<<"D";

else
cout<<"*";

j++;

}

cout<<endl;
}

return 0;
}


#include<bits/stdc++.h>

using namespace std;
string s[1001];
string s1[1001];
int main(){
int n;
bool b=false;
cin>>n;
int odd=1,odd1=0;
for(int i=0;i<n;i++)
{

if(odd<=n){
        odd1++;
    for(int w=0;w<(n-odd)/2;w++)
        cout<<"*",s[odd1]+="*";

     for(int e=0;e<odd;e++)
                cout<<"D",s1[odd1]+="D";

        cout<<s[odd1];
if(odd==n)b=true;
        odd+=2;

        cout<<endl;   }
        if(b){odd1--;cout<<s[odd1]<<s1[odd1]<<s[odd1]<<endl;

        }

}

return 0;  }


#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n/2+1;++i)
    {
        for(int j=1;j<=n/2-i+1;++j)
            cout<<"*";
        for(int j=1;j<=2*i-1;++j)cout<<"D";
        for(int j=1;j<=n/2-i+1;++j)
            cout<<"*";
        cout<<endl;
    }

    for(int i=1;i<=n/2;++i)
    {
        for(int j=1;j<=i;++j)
            cout<<"*";
        for(int j=1;j<=n-i*2;++j)cout<<"D";
        for(int j=1;j<=i;++j)
            cout<<"*";
        cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define maxn 1010101
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define L long long
int a[110][110],n;
int main(){
    cin>>n;
    int space=(n-1)/2;
    FOR(i,0,n){
        //int d=space;
        FOR(j,0,space){
            a[i][j]=a[i][n-j-1]=1;
        }
        if(i<n/2)  space--;
        else        space++;
        cout<<space<<endl;
    }
    FOR(i,0,n){
        FOR(j,0,n)
        {
            if(a[i][j]==1)  cout<<"*";
            if(a[i][j]==0)  cout<<"D";
        }
        cout<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define maxn 1010101
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define L long long
int a[110][110],n;
int main(){
    cin>>n;
    int space=(n-1)/2;
    FOR(i,0,n){
        //int d=space;
        FOR(j,0,space){
            a[i][j]=a[i][n-j-1]=1;
        }
        if(i<n/2)  space--;
        else        space++;
    }
    FOR(i,0,n){
        FOR(j,0,n)
        {
            if(a[i][j]==1)  cout<<"*";
            if(a[i][j]==0)  cout<<"D";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define pb push_back
#define lcm(a,b) a * (b / gcd(a, b))
#define gcd(a,b) __gcd(a,b)
#define nl "\n"
#define inf 2e16
#define MAX (int)2e5+5
#define pi	acos(-1.0)
#define ff first
#define ss second
#define mp make_pair
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define sqr(a) ((a)*(a))
#define mem(a,x) memset(a,x,sizeof(a))
#define RL(x) scanf("%lld",&x)
#define R(x) scanf("%d",&x)
#define RS(x) cin>>s
//#define RSL(x) scanf(" %[^\n]", x)
#define RSL(cin, x) getline(cin, x)
#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())
#define f(i,a,b) for(int i = a; i<=b;i++)
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int main()
{
   IOS
        int n;
        R(n);
        int space = n / 2;
        for(int i = 0; i<n;i++){
            int D = n - (space*2);
                for(int j = 0; j<space;j++){
                    cout<<"*";
                }
                for(int j = 0; j<D;j++){
                    cout<<"D";
                }
                for(int j = 0; j<space;j++){
                    cout<<"*";
                }
                cout<<nl;
                if(i<n/2){
                    space--;
                }
                else space++;
        }

     return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define pb push_back
#define lcm(a,b) a * (b / gcd(a, b))
#define gcd(a,b) __gcd(a,b)
#define nl "\n"
#define inf 2e16
#define pi	acos(-1.0)
#define ff first
#define ss second
#define mp make_pair
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define sqr(a) ((a)*(a))
#define mem(a,x) memset(a,x,sizeof(a))
#define RL(x) scanf("%lld",&x)
#define R(x) scanf("%d",&x)
#define RS(x) cin>>s
//#define RSL(x) scanf(" %[^\n]", x)
#define RSL(cin, x) getline(cin, x)
#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())
#define f(i,a,b) for(int i = a; i<=b;i++)
int main()
{
     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

        int n;
        R(n);
        int l  = n/2;
        int r = n/2;
        for(int i = 0; i<n;i++)
        {
            for(int j = 0; j<n;j++)
            {
                if(j>=l and j<=r){
                    cout<<"D";
                }
                else
                    cout<<"*";
            }
            if(i<n/2){
                l--;
                r++;
            }
            else  if(i>=n/2){
                l++;
                r--;
            }
            cout<<nl;
        }

     return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin >> n;
	for (int i = 0; i < n / 2; i++)
	{
		for (int j = 0; j < n / 2 - i; j++)
			cout << '*';
		for (int j = 0; j < i * 2 + 1; j++)
			cout << 'D';
		for (int j = 0; j < n / 2 - i; j++)
			cout << '*';
		cout << endl;
	}
	for (int i = 0; i < n; i++)
		cout << 'D';
	cout << endl;
	for (int i = n / 2; i >= 0; i--)
	{
		for (int j = 0; j < n / 2 - i; j++)
			cout << '*';
		for (int j = 0; j < i * 2 + 1; j++)
			cout << 'D';
		for (int j = 0; j < n / 2 - i; j++)
			cout << '*';
		cout << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin >> n;
	for (int i = 0; i < n / 2; i++)
	{
		for (int j = 0; j < n / 2 - i; j++)
			cout << '*';
		for (int j = 0; j < i * 2 + 1; j++)
			cout << 'D';
		for (int j = 0; j < n / 2 - i; j++)
			cout << '*';
		cout << endl;
	}
	for (int i = n / 2; i >= 0; i--)
	{
		for (int j = 0; j < n / 2 - i; j++)
			cout << '*';
		for (int j = 0; j < i * 2 + 1; j++)
			cout << 'D';
		for (int j = 0; j < n / 2 - i; j++)
			cout << '*';
		cout << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
      int n,i,j;
      cin>>n;
      a=n/2,b=n/2;
      for(i=0;i<=n/2;i++){
            for(j=0;j<n;j++){
                  if(j>=a&&j<=b)
                  cout<<"D";
                  else
                  cout<<"*";

            }
            a--;
            b++;
            cout<<endl;

      }
      a++;
      b--;
      for(i=n/2+1;i<n;i++){
            for(j=0;j<n;j++){
                   if(j>=a&&j<=b)
                  cout<<"D";
                  else
                  cout<<"*";

            }
            a++;
            b--;
            cout<<endl;
      }

      return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
      int n,i,j,a,b;
      cin>>n;
      a=n/2,b=n/2;
      for(i=0;i<=n/2;i++){
            for(j=0;j<n;j++){
                  if(j>=a&&j<=b)
                  cout<<"D";
                  else
                  cout<<"*";

            }
            a--;
            b++;
            cout<<endl;

      }
      a++;
      b--;
      for(i=n/2+1;i<n;i++){
            for(j=0;j<n;j++){
                   if(j>=a&&j<=b)
                  cout<<"D";
                  else
                  cout<<"*";

            }
            a++;
            b--;
            cout<<endl;
      }

      return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
      int n,i,j,a,b;
      cin>>n;
      a=n/2,b=n/2;
      for(i=0;i<=n/2;i++){
            for(j=0;j<n;j++){
                  if(j>=a&&j<=b)
                  cout<<"D";
                  else
                  cout<<"*";

            }
            a--;
            b++;
            cout<<endl;

      }
      a+=2;
      b+=2;
      for(i=n/2+1;i<n;i++){
            for(j=0;j<n;j++){
                   if(j>=a&&j<=b)
                  cout<<"D";
                  else
                  cout<<"*";

            }
            a++;
            b--;
            cout<<endl;
      }

      return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
      int n,i,j,a,b;
      cin>>n;
      a=n/2,b=n/2;
      for(i=0;i<=n/2;i++){
            for(j=0;j<n;j++){
                  if(j>=a&&j<=b)
                  cout<<"D";
                  else
                  cout<<"*";

            }
            a--;
            b++;
            cout<<endl;

      }
      a+=2;
      b-=2;
      for(i=n/2+1;i<n;i++){
            for(j=0;j<n;j++){
                   if(j>=a&&j<=b)
                  cout<<"D";
                  else
                  cout<<"*";

            }
            a++;
            b--;
            cout<<endl;
      }

      return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
      int n,i,j,a=n/2,b=n/2;
      cin>>n;
      for(i=0;i<=n/2;i++){
            for(j=0;j<n;j++){
                  if(j>=a&&j<=b)
                  cout<<"D";
                  else
                  cout<<"*";

            }
            a--;
            b++;
            cout<<endl;

      }
      a++;
      b--;
      for(i=n/2+1;i<n;i++){
            for(j=0;j<n;j++){
                   if(j>=a&&j<=b)
                  cout<<"D";
                  else
                  cout<<"*";

            }
            a++;
            b--;
            cout<<endl;
      }

      return 0;
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int c=n-2;
	for(int i=0;i<n/2+1;i++)
	{

		for(int j=n/2 ;j>=i+1 ;j--)
		{cout<<"*";}

		for(int j=1 ;j<=i*2+1;j++)
		{cout<<"D";}

		for(int j=n/2 ;j>=i+1 ;j--)
		{cout<<"*";}

		cout<<endl;

	}

		for(int i=1;i<=n/2;i++)
	{

		for(int j=0 ;j<i ;j++)
		{cout<<"*";}

		for(int a=1 ;a<=c;a++)
		{cout<<"D";}
		 c=c-2;

		for(int j=0 ;j<i ;j++)
		{cout<<"*";}

		cout<<endl;

	}

}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int c=n-2;
	for(int i=0;i<n/2+1;i++)
	{

		for(int j=n/2 ;j>=i+1 ;j--)
		{cout<<"*";}

		for(int j=1 ;j<=i*2+1;j++)
		{cout<<"D";}

		for(int j=n/2 ;j>=i+1 ;j--)
		{cout<<"*";}

		cout;

	}

		for(int i=1;i<=n/2;i++)
	{

		for(int j=0 ;j<i ;j++)
		{cout<<"*";}

		for(int j=1 ;j<=c;j++)
		{cout<<"D";}
		 c=c-2;

		for(int j=0 ;j<i ;j++)
		{cout<<"*";}

		cout<<endl;

	}

}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int c=n-2;
	for(int i=0;i<n/2+1;i++)
	{

		for(int j=n/2 ;j>=i+1 ;j--)
		{cout<<"*";}

		for(int j=1 ;j<=i*2+1;j++)
		{cout<<"D";}

		for(int j=n/2 ;j>=i+1 ;j--)
		{cout<<"*";}

		cout<<endl;

	}

		for(int i=1;i<=n/2;i++)
	{

		for(int j=0 ;j<i ;j++)
		{cout<<"*";}

		for(int j=1 ;j<=c;j++)
		{cout<<"D";}
		 c=c-2;

		for(int j=0 ;j<i ;j++)
		{cout<<"*";}

		cout<<endl;

	}

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=2e5+50;
const int inf=1e9;
typedef unsigned long long ull;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    int n;
    cin>>n;
    int mid=n/2;
    for(int i=1;i<=mid;i++){
        for(int j=1;j<=n;j++){
            if(j<=mid-i+1||j>=mid+i+1)cout<<'*';
            else cout<<'D';
        }
        cout<<endl;
    }
    for(int i=1;i<=n;i++)cout<<'D';cout<<endl;
    for(int i=mid;i;i--){
        for(int j=1;j<=n;j++){
            if(j<=mid-i+1||j>=mid+i+1)cout<<'*';
            else cout<<'D';
        }
        cout<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=2e5+50;
const int inf=1e9;
typedef unsigned long long ull;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    int n;
    cin>>n;
    int mid=n/2;
    cout<<mid+1<<endl;
    for(int i=1;i<=mid;i++){
        for(int j=1;j<=n;j++){
            if(j<=mid-i+1||j>=mid+i+1)cout<<'*';
            else cout<<'D';
        }
        cout<<endl;
    }
    for(int i=1;i<=n;i++)cout<<'D';cout<<endl;
    for(int i=mid;i;i--){
        for(int j=1;j<=n;j++){
            if(j<=mid-i+1||j>=mid+i+1)cout<<'*';
            else cout<<'D';
        }
        cout<<endl;
    }

    return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string s[102][102];
int main()
{
int n,y=0,t=0;
cin>>n;

for(int i=0;i<n/2+1;++i){
    for(int j=0;j<n;++j)
    s[i][j]='*';

}

for(int i=0;i<n/2+1;++i){
    y=(i*2)+1;
    t=n-y;
int j=t/2;
while(y--){
        s[i][j]='D';
        ++j;
}
}
for(int i=0;i<n/2+1;++i){
    for(int j=0;j<n;++j)
    cout<<s[i][j];
cout<<endl;
}
for(int i=n/2-1;i>=0;--i){
    for(int j=0;j<n;++j)
    cout<<s[i][j];
    cout<<endl;
}
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string s[100][100];
int main()
{
int n,y=0,t=0;
cin>>n;

for(int i=0;i<n/2+1;++i){
    for(int j=0;j<n;++j)
    s[i][j]='*';

}

for(int i=0;i<n/2+1;++i){
    y=(i*2)+1;
    t=n-y;
int j=t/2;
while(y--){
        s[i][j]='D';
        ++j;
}
}
for(int i=0;i<n/2+1;++i){
    for(int j=0;j<n;++j)
    cout<<s[i][j];
cout<<endl;
}
for(int i=n/2-1;i>=0;--i){
    for(int j=0;j<n;++j)
    cout<<s[i][j];
    cout<<endl;
}
}


#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if ( n == 3 ){
        cout << "*D*\n";
        cout << "DDD\n";
        cout << "*D*";
        return 0;
    }
    for ( int i = 1; i <= (n+1) / 2; i ++ ){
        for ( int j = 2; j < n-i; j++ ){
            cout << "*";
        }
        for ( int j = (2 * i) - 1; j > 0; j-- ){
            cout << "D";
        }
        for ( int j = 2; j < n-i; j++ ){
            cout << "*";
        }
        cout << endl;
    }
    for ( int i = n / 2; i > 0; i -- ){
        for ( int j = 2; j < n-i; j++ ){
            cout << "*";
        }
        for ( int j = (2 * i) - 1; j > 0; j-- ){
            cout << "D";
        }
        for ( int j = 2; j < n-i; j++ ){
            cout << "*";
        }
        cout << endl;
    }
}


#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int l = (n) / 2;
    int r = 1;
    for ( int i = 1; i <= (n+1) / 2; i ++ ){
        for ( int j = 0; j <l; j++ ){
            cout << "*";
        }
        for ( int j = (2 * i) - 1; j > 0; j-- ){
            cout << "D";
        }
        for ( int j = 0; j < l; j++ ){
            cout << "*";
        }
        cout << endl;
        l--;
    }
    for ( int i = n / 2; i > 0; i -- ){
        for ( int j = 0; j < r; j++ ){
            cout << "*";
        }
        for ( int j = (2 * i) - 1; j > 0; j-- ){
            cout << "D";
        }
        for ( int j = 0; j < r; j++ ){
            cout << "*";
        }
        cout << endl;
        r++;
    }
}


#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    for ( int i = 1; i <= (n+1) / 2; i ++ ){
        for ( int j = 2; j < n-i; j++ ){
            cout << "*";
        }
        for ( int j = (2 * i) - 1; j > 0; j-- ){
            cout << "D";
        }
        for ( int j = 2; j < n-i; j++ ){
            cout << "*";
        }
        cout << endl;
    }
    for ( int i = n / 2; i > 0; i -- ){
        for ( int j = 2; j < n-i; j++ ){
            cout << "*";
        }
        for ( int j = (2 * i) - 1; j > 0; j-- ){
            cout << "D";
        }
        for ( int j = 2; j < n-i; j++ ){
            cout << "*";
        }
        cout << endl;
    }
}


using namespace std ;
#include "iostream"
#include "stdio.h"
#include "algorithm"
#include "cstring"
#include "cmath"
#include "set"
#include "vector"
#include "iomanip"
#include "stack"
#include "cctype"
typedef long long lld;
#define MAX 200
#define CFT int ACCEPTED = 1 ;
#define MYT int ACCEPTED = 1000 ;
#define T_ISA ACCEPTED--
#define AlhamdwLeAllah return 0
#define el '\n'
void SpeedIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int SD()
{
    int x;
    scanf("%d",&x);
    return x;
}
lld SLL()
{
    lld x;
    scanf("%lld",&x);
    return x;
}
const int AKA = 5e5 + 5 ;
int cm [AKA];
int idx [AKA], a [AKA], b [AKA];
int arr[AKA];
bool cpm (int s, int f)
{
    if(b [f] < b[s])
        return true;
    if(b[f] == b[s] && a[f] < a[s])
        return true;
    return false;
}
int main()
{
    CFT;
    while(T_ISA)
    {
        int n=SD();
        for ( int i = 0 ; i < n/2 ; ++i )
        {
            int rem = (n-(i<<1)-1)/2 ;
            for ( int j = 0 ; j < rem ; ++j ) cout << '*' ;
            for ( int j = i*2 ; j >= 0 ; --j ) cout << 'D' ;
            for ( int j = 0 ; j < rem ; ++j ) cout << '*' ;
            cout << "\n";
        }
        for ( int i = 0 ; i < n ; ++i ) cout << 'D' ;
        cout << '\n';
        for ( int i = n/2-1 ; i >= 0 ; --i )
        {
            int rem = (n-(i<<1)-1)/2 ;
            for ( int j = 0 ; j < rem ; ++j ) cout << '*' ;
            for ( int j = i*2 ; j >= 0 ; --j ) cout << 'D' ;
            for ( int j = 0 ; j < rem ; ++j ) cout << '*' ;
            cout << "\n";
        }

    }
    AlhamdwLeAllah;
}
/*
  *
 ***
*****

                                ───█───▄▀█▀▀█▀▄▄───▐█──────▄▀█▀▀█▀▄▄
                                ──█───▀─▐▌──▐▌─▀▀──▐█─────▀─▐▌──▐▌─█▀
                                ─▐▌──────▀▄▄▀──────▐█▄▄──────▀▄▄▀──▐▌
                                ─█────────────────────▀█────────────█
                                ▐█─────────────────────█▌───────────█
                                ▐█─────────────────────█▌───────────█
                                ─█───────────────█▄───▄█────────────█
                                ─▐▌───────────────▀███▀────────────▐▌
                                ──█──────────▀▄───────────▄▀───────█
                                ───█───────────▀▄▄▄▄▄▄▄▄▄▀────────█

▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬ > Made By Screaming Eagle AhMeD SaLaH  <▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬>
*/


using namespace std ;
#include "iostream"
#include "stdio.h"
#include "algorithm"
#include "cstring"
#include "cmath"
#include "set"
#include "vector"
#include "iomanip"
#include "stack"
#include "cctype"
typedef long long lld;
#define MAX 200
#define CFT int ACCEPTED = 1 ;
#define MYT int ACCEPTED = 1000 ;
#define T_ISA ACCEPTED--
#define AlhamdwLeAllah return 0
#define el '\n'
void SpeedIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int SD()
{
    int x;
    scanf("%d",&x);
    return x;
}
lld SLL()
{
    lld x;
    scanf("%lld",&x);
    return x;
}
const int AKA = 5e5 + 5 ;
int cm [AKA];
int idx [AKA], a [AKA], b [AKA];
int arr[AKA];
bool cpm (int s, int f)
{
    if(b [f] < b[s])
        return true;
    if(b[f] == b[s] && a[f] < a[s])
        return true;
    return false;
}
int main()
{
    CFT;
    while(T_ISA)
    {
        int n=SD();
        int n1=n/2 , n2=n-n1-1 ;
        for(int line=0;line <= n1;++line)
        {
            for(int star=0;star<n1-line;++star)
                printf("*");
            for(int D=0;D<line*2+1;++D)
                printf("D");
            for(int star=0;star<n1-line;++star)
                printf("*");
            printf("\n");
        }
        for(int line=0;line < n2;++line)
        {
            for(int star=0;star<line+1;++star)
                printf("*");
            for(int D=0;D<(n-2)-2*line;++D)
               printf("D");
            for(int star=0;star<line+1;++star)
                printf("*");
            printf("\n");
        }

    }
    AlhamdwLeAllah;
}
/*
  *
 ***
*****

                                ───█───▄▀█▀▀█▀▄▄───▐█──────▄▀█▀▀█▀▄▄
                                ──█───▀─▐▌──▐▌─▀▀──▐█─────▀─▐▌──▐▌─█▀
                                ─▐▌──────▀▄▄▀──────▐█▄▄──────▀▄▄▀──▐▌
                                ─█────────────────────▀█────────────█
                                ▐█─────────────────────█▌───────────█
                                ▐█─────────────────────█▌───────────█
                                ─█───────────────█▄───▄█────────────█
                                ─▐▌───────────────▀███▀────────────▐▌
                                ──█──────────▀▄───────────▄▀───────█
                                ───█───────────▀▄▄▄▄▄▄▄▄▄▀────────█

▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬ > Made By Screaming Eagle AhMeD SaLaH  <▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬>
*/


using namespace std ;
#include "iostream"
#include "stdio.h"
#include "algorithm"
#include "cstring"
#include "cmath"
#include "set"
#include "vector"
#include "iomanip"
#include "stack"
#include "cctype"
typedef long long lld;
#define MAX 200
#define CFT int ACCEPTED = 1 ;
#define MYT int ACCEPTED = 1000 ;
#define T_ISA ACCEPTED--
#define AlhamdwLeAllah return 0
#define el '\n'
void SpeedIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int SD()
{
    int x;
    scanf("%d",&x);
    return x;
}
lld SLL()
{
    lld x;
    scanf("%lld",&x);
    return x;
}
const int AKA = 5e5 + 5 ;
int cm [AKA];
int idx [AKA], a [AKA], b [AKA];
int arr[AKA];
bool cpm (int s, int f)
{
    if(b [f] < b[s])
        return true;
    if(b[f] == b[s] && a[f] < a[s])
        return true;
    return false;
}
int main()
{
    CFT;
    while(T_ISA)
    {
        int n=SD();
        n/=2;
        for(int line=0;line <= n;++line)
        {
            for(int star=0;star<n-line;++star)
                printf("*");
            for(int D=0;D<line*2+1;++D)
                printf("D");
            for(int star=0;star<n-line;++star)
                printf("*");
            printf("\n");
        }
        for(int line=0;line < n;++line)
        {
            for(int star=0;star<line+1;++star)
                printf("*");
            for(int D=0;D<5-2*line;++D)
                printf("D");
            for(int star=0;star<line+1;++star)
                printf("*");
            printf("\n");
        }

    }
    AlhamdwLeAllah;
}
/*
  *
 ***
*****

                                ───█───▄▀█▀▀█▀▄▄───▐█──────▄▀█▀▀█▀▄▄
                                ──█───▀─▐▌──▐▌─▀▀──▐█─────▀─▐▌──▐▌─█▀
                                ─▐▌──────▀▄▄▀──────▐█▄▄──────▀▄▄▀──▐▌
                                ─█────────────────────▀█────────────█
                                ▐█─────────────────────█▌───────────█
                                ▐█─────────────────────█▌───────────█
                                ─█───────────────█▄───▄█────────────█
                                ─▐▌───────────────▀███▀────────────▐▌
                                ──█──────────▀▄───────────▄▀───────█
                                ───█───────────▀▄▄▄▄▄▄▄▄▄▀────────█

▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬ > Made By Screaming Eagle AhMeD SaLaH  <▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬>
*/


// http://codeforces.com/problemset/problem/454/A

#include <bits/stdc++.h>
using namespace std;

int main() {

	int n;
	cin>>n;

	for(int i=1; i<=n; i++) {
		if(i%2 == 0) {continue;}
		for(int j=1; j<=(n-i)/2; j++) {cout<<'*';}
		for(int j=1; j<=i; j++) {cout<<'D';}
		for(int j=1; j<=(n-i)/2; j++) {cout<<'*';}
		cout<<endl;
	}

	for(int i=1; i<=n/2; i++) {
	    for(int j=1; j<=i; j++) {cout<<'*';}
	    for(int j=1; j<=(n - 2*i); j++) {cout<<'D';}
	    for(int j=1; j<=i; j++) {cout<<'*';}
	    cout<<endl;
	}

	return 0;
}


// http://codeforces.com/problemset/problem/454/A

#include <bits/stdc++.h>
using namespace std;

int main() {

	int n;
	cin>>n;

	for(int i=1; i<=n; i++) {
		for(int j=1; j<=(n-i)/2; j++) {cout<<'*';}
		for(int j=1; j<=i; j++) {cout<<'D';}
		for(int j=1; j<=(n-i)/2; j++) {cout<<'*';}
		cout<<endl;
	}

	return 0;
}


#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
int n;
cin>>n;

int x=n/2;

vector<char>ch(n,'*');
int t=1,r=1;
ch[x]='D';

for(int i=0;i<n;++i)
	cout<<ch[i];
cout<<"\n";
for(int i=0;i<x;++i)
{
	ch[x+t]='D';ch[x-r]='D';
	for(int i=0;i<n;++i)
	{
		cout<<ch[i];
	}
	cout<<"\n";
	++t;++r;
}
t=0;r=n-1;
for(int i=0;i<x;++i)
{
	ch[t]='*';ch[r]='*';
	for(int j=0;j<n;++j)
		cout<<ch[j];
	cout<<"\n";
	++t;--r;
}
return 0;
}


#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n/2+1;++i)
    {
        for(int j=1;j<=n/2-i+1;++j)
            cout<<"*";
        for(int j=1;j<=2*i-1;++j)cout<<"D";
        for(int j=1;j<=n/2-i+1;++j)
            cout<<"*";
        cout<<endl;
    }

    for(int i=1;i<=n/2;++i)
    {
        for(int j=1;j<=i;++j)
            cout<<"*";
        for(int j=1;j<=n-i*2;++j)cout<<"D";
        for(int j=1;j<=i;++j)
            cout<<"*";
        cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define LL          long long int
#define ULL         unsigned long long
#define lc          idx * 2
#define rc          lc | 1
#define pb          push_back
#define pf          push_front
#define S           second
#define F           first
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define si(x)       scanf("%d", &x);
#define sll(x)      scanf("%lld", &x);
#define pi(x)       printf("%d", x);
#define pll(x)      printf("%lld", x);
#define sp          printf(" ");
#define nl          printf("\n");

#define dbg(x)          cerr << #x << " : " << x << endl;
#define dbg2(x, y)      cerr << #x << " : " << x << " " << #y << " : " << y << endl;
#define dbg3(x, y, z)   cerr << #x << " : " << x << " " << #y << " : " << y << " " << #z << " : " << z << endl;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;

const LL  INF = 1600000000000000000LL;   // 1.6 * 10^18
const int MOD = 1000000007;              // 1e9 + 7
double eps = 0.0000000001;

LL fpow(LL a,LL b,LL mo=MOD){LL res=1;a%=mo; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
inline LL inv(LL a) {return fpow(a, MOD-2, MOD);}

//cout << fixed << setprecision(8);

/*
    int start_s=clock();
    // the code you wish to time goes here
    int stop_s=clock();
    cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC) << endl;
*/

const int dx8[] = {1, 1, 0, -1, -1, -1, 0,1};
const int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx4[] = {0, 0, 1, -1};
const int dy4[] = {1, -1, 0, 0};

map< pair<int, int> , int> DP;

int n;
char a[101][101];

int main()
{
    cin >> n;

    int st = n / 2 + 1;

    int c = 0;
    int yum = 0;
    while(st > 0)
    {
        int l = 1;
        int r = n;
        c = yum;
        while(c > 0)
        {
            a[st][l] = '*';
            a[st][r] = '*';
            l++;
            r--;
            c--;
        }

        while(l <= r)a[st][l++] = 'D';
        c++;
        st--;
        ++yum;
    }

    st = n / 2 + 2;
    yum = 1;
    while(st <= n)
    {
        int l = 1;
        int r = n;
        c = yum;
        while(c > 0)
        {
            a[st][l] = '*';
            a[st][r] = '*';
            l++;
            r--;
            c--;
        }

        while(l <= r)a[st][l++] = 'D';
        c++;
        st++;
        yum++;
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cout << a[i][j];
        }cout << endl;
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define LL          long long int
#define ULL         unsigned long long
#define lc          idx * 2
#define rc          lc | 1
#define pb          push_back
#define pf          push_front
#define S           second
#define F           first
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define si(x)       scanf("%d", &x);
#define sll(x)      scanf("%lld", &x);
#define pi(x)       printf("%d", x);
#define pll(x)      printf("%lld", x);
#define sp          printf(" ");
#define nl          printf("\n");

#define dbg(x)          cerr << #x << " : " << x << endl;
#define dbg2(x, y)      cerr << #x << " : " << x << " " << #y << " : " << y << endl;
#define dbg3(x, y, z)   cerr << #x << " : " << x << " " << #y << " : " << y << " " << #z << " : " << z << endl;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;

const LL  INF = 1600000000000000000LL;   // 1.6 * 10^18
const int MOD = 1000000007;              // 1e9 + 7
double eps = 0.0000000001;

LL fpow(LL a,LL b,LL mo=MOD){LL res=1;a%=mo; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
inline LL inv(LL a) {return fpow(a, MOD-2, MOD);}

//cout << fixed << setprecision(8);

/*
    int start_s=clock();
    // the code you wish to time goes here
    int stop_s=clock();
    cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC) << endl;
*/

const int dx8[] = {1, 1, 0, -1, -1, -1, 0,1};
const int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx4[] = {0, 0, 1, -1};
const int dy4[] = {1, -1, 0, 0};

map< pair<int, int> , int> DP;

int n;
char a[222][222];

int main()
{
    cin >> n;

    int st = n / 2 + 1;

    int c = 0;
    int yum = 0;
    while(st > 0)
    {
        int l = 1;
        int r = n;
        c = yum;
        while(c > 0)
        {
            a[st][l] = '*';
            a[st][r] = '*';
            l++;
            r--;
            c--;
        }

        while(l <= r)a[st][l++] = 'D';
        c++;
        st--;
        ++yum;
    }

    st = n / 2 + 2;
    yum = 1;
    while(st <= n)
    {
        int l = 1;
        int r = n;
        c = yum;
        while(c > 0)
        {
            a[st][l] = '*';
            a[st][r] = '*';
            l++;
            r--;
            c--;
        }

        while(l <= r)a[st][l++] = 'D';
        c++;
        st++;
        yum++;
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cout << a[i][j];
        }cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
bool check ;
int main ()
{
    int n; cin>>n; int x=n/2 , y=1 , z=n ;
    while ( z-- ) {
//        cout << x << ' ' << y << endl ;
        for ( int j=0 ; j<x ; j++ ) cout << '*' ;
        for ( int j=0 ; j<y ; j++ ) cout << 'D' ;
        for ( int j=0 ; j<x ; j++ ) cout << '*' ;
        cout << endl ;
        if ( y == n ) check = true ;
        if ( check ) x+=1 , y-=2 ;
        else x-=1 , y+=2 ;
    }
    return EXIT_SUCCESS ;
}


#include <bits/stdc++.h>
using namespace std;
bool check ;
int main ()
{
    int n; cin>>n; int x=n/2 , y=1 ;
    for ( int i=0 ; i<n ; i++ ) {
        for ( int j=0 ; j<x ; j++ ) cout << '*' ;
        for ( int j=0 ; j<y ; j++ ) cout << 'D' ;
        for ( int j=0 ; j<x ; j++ ) cout << '*' << endl ;
        if ( y == n ) cout << endl , check = true ;
        if ( !check ) x-=2 , y+=2 ;
        else x+=2 , y-=2 ;
    }
    return EXIT_SUCCESS ;
}


#include <bits/stdc++.h>
using namespace std;
bool check ;
int main ()
{
    int n; cin>>n; int x=n/2 , y=1 ;
    for ( int i=0 ; i<n ; i++ ) {
        for ( int j=0 ; j<x ; j++ ) cout << '*' ;
        for ( int j=0 ; j<y ; j++ ) cout << 'D' ;
        for ( int j=0 ; j<x ; j++ ) cout << '*' << endl ;
        if ( y == n ) check = true ;
        if ( !check ) x-=2 , y+=2 ;
        else x+=2 , y-=2 ;
    }
    return EXIT_SUCCESS ;
}


#include <iostream>

using namespace std;

int main()
{
    int x;
    cin>>x;
    int star=x/2;
    if(x>2&&x<=101&&x%2!=0){
        for(int i=0;i<x;i+=2){
            for(int j=0;j<star;j++){
                cout<<"*";
            }

            for(int n=0;n<=i;n++){
                cout<<"D";
            }
            for(int j=0;j<star;j++){
                cout<<"*";
            }
            star--;
            cout<<endl;
        }
        ///rev
        star=1;
        for(int i=x-2;i>0;i-=2){
            for(int j=0;j<star;j++){
                cout<<"*";
            }

            for(int n=0;n<=i;n++){
                cout<<"D";
            }
            for(int j=0;j<star;j++){
                cout<<"*";
            }
            star++;
            cout<<endl;
        }

    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int x;
    cin>>x;
    int star=x/2;
    if(x>2&&x<=101&&x%2!=0){
        for(int i=0;i<x;i+=2){
            for(int j=0;j<star;j++){
                cout<<"*";
            }

            for(int n=0;n<=i;n++){
                cout<<"D";
            }
            for(int j=0;j<star;j++){
                cout<<"*";
            }
            star--;
            cout<<endl;
        }
        ///rev
        star=1;
        for(int i=x-2;i>0;i-=2){
            for(int j=0;j<star;j++){
                cout<<"*";
            }

            for(int n=0;n<i;n++){
                cout<<"D";
            }
            for(int j=0;j<star;j++){
                cout<<"*";
            }
            star++;
            cout<<endl;
        }

    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin >> n;
	char arr[n][n];
	for(int i = 0; i <= n/2; i++)
	{
		for(int k = 0; k < n; k++)
			arr[i][k] = '*';

		for(int j = n/2 - i; j <= n/2 + i ; j++)
			arr[i][j] = 'D';
	}
	for(int i = 0; i <= n/2; i++)
	{
		for(int  j = 0; j < n; j++)
			cout << arr[i][j];
		cout << "\n";
	}

	for(int i = n/2 - 1; i >= 0; i--)
	{
		for(int  j = 0; j < n; j++)
			cout << arr[i][j] ;
		cout << "\n";
	}

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin >> n;
	char arr[n][n];
	for(int i = 0; i <= n/2; i++)
	{
		for(int k = 0; k < n; k++)
			arr[i][k] = '*';

		for(int j = n/2 - i; j <= n/2 + i ; j++)
			arr[i][j] = 'D';
	}
	for(int i = 0; i <= n/2; i++)
	{
		for(int  j = 0; j < n; j++)
			cout << arr[i][j] << " " ;
		cout << "\n";
	}

	for(int i = n/2 - 1; i >= 0; i--)
	{
		for(int  j = 0; j < n; j++)
			cout << arr[i][j] << " " ;
		cout << "\n";
	}

	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define maxx 1000000005
#define MOD 1000003
#define sf(n) scanf("%lld", &n);
#define sff(n,m) scanf("%lld %lld", &n, &m)
#define pf(n) printf("%lld\n", n)
#define pff(n,m) printf("%lld %lld\n", n, m)
#define mem(a) memset(a, 0, sizeof(a))
#define fr(i,n) for(ll i=0; i<n; i++)
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
#define pi 2*acos(0.0)
#define F first
#define S second
#define EPS 1e-9

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    while(cin >> n){
        for(int i = 1; i <= n/2+1; i++){
            int x = i * 2 - 1;
            int j = (n - x)  / 2 + 1;
            for(int k = 1; k < j;k++)
                cout << '*';
            for(;x;x--,j++)
                cout << 'D';
            for(; j <= n;j++)
                cout << '*';
                cout << endl;
        }
        for(int i = n/2+2; i<= n; i++){
            int x = (n-i+1) * 2 - 1;
            int j = (n - x)  / 2 + 1;
            for(int k = 1; k < j;k++)
                cout << '*';
            for(;x;x--,j++)
                cout << 'D';
            for(; j <= n;j++)
                cout << '*';
                cout << endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define maxx 1000000005
#define MOD 1000003
#define sf(n) scanf("%lld", &n);
#define sff(n,m) scanf("%lld %lld", &n, &m)
#define pf(n) printf("%lld\n", n)
#define pff(n,m) printf("%lld %lld\n", n, m)
#define mem(a) memset(a, 0, sizeof(a))
#define fr(i,n) for(ll i=0; i<n; i++)
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
#define pi 2*acos(0.0)
#define F first
#define S second
#define EPS 1e-9

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    while(cin >> n){
        string a[105];
        for(int i = 1; i <= n; i++){
            for(int j =1; j <= n; j++)
                a[i][j] = '*';
        }
        for(int i = 1; i <= n/2+1; i++){
            int x = i * 2 - 1;
            int j = (n - x)  / 2 + 1;
            while(x){
                a[i][j] = 'D';
                x--;
                j++;
            }
        }
        for(int i = n; i >= n/2+2; i--){
            int x = (n-i+1) * 2 - 1;
            int j = (n - x)  / 2 + 1;
            while(x){
                a[i][j] = 'D';
                x--;
                j++;
            }
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++)
                cout << a[i][j];
            cout << endl;
        }
    }

    return 0;
}


//https://www.youtube.com/channel/UC6A6l69_BpUxRJ-sdw95qSg/videos?view_as=subscriber

#include <bits/stdc++.h>
#define fr first
#define r_0 return 0
#define sc scanf
#define pf printf
#define se second
#define ll long long
#define pb push_back
#define puf push_front
#define mk make_pair
#define ld long double
#define fin(s) freopen( s, "r",stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 5e2 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

/*
for ( int i=0; i<s.size(); i++ )
    v.push_back(int (s[i]) - 48);
*/

string solve( int nn, string ss )
{
    for ( int i=0; i<nn; i++ )
        {
            if ( i == nn / 2 )
                ss += 'D';
            else
                ss += '*';
         }
         return ss;
}
string nike ( int nnn, string ttt )
{
    for ( int i=0; i<nnn; i++ )
        ttt += 'D';
        return ttt;
}

string s,t;
ll int n, a[N], x = 1;
vector< string > v, V;
int main()
{
    cin >> n;
    s = solve( n, s );
    for ( int i=1; i<=n / 2; i++ ){
        v.pb( s );
        cout << s << endl ;
        s[(n / 2) - i] = 'D';
        s[(n / 2) + i] = 'D';
    }
    t = nike( n, t );
    cout << t << endl;
    reverse(v.begin(), v.end());
    for ( int i=0; i<v.size(); i++ )
        cout << v[i] << endl;
}


//https://www.youtube.com/channel/UC6A6l69_BpUxRJ-sdw95qSg/videos?view_as=subscriber

#include <bits/stdc++.h>
#define fr first
#define r_0 return 0
#define sc scanf
#define pf printf
#define se second
#define ll long long
#define pb push_back
#define puf push_front
#define mk make_pair
#define ld long double
#define fin(s) freopen( s, "r",stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 5e2 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

/*
for ( int i=0; i<s.size(); i++ )
    v.push_back(int (s[i]) - 48);
*/

ll int n, a[N], x = 1;
vector< string > v, V;
int main()
{
    string s,t;
    cin >> n;
    for ( int i=0; i<n; i++ )
        {
            t += 'D';
            if ( i == n / 2 )
                s += 'D';
            else
                s+= '*';
         }
    for ( int i=1; i<=n / 2; i++ )
    {
        v.pb( s );
        cout << s << endl ;
        s[(n / 2) - i] = 'D';
        s[(n / 2) + i] = 'D';
    }
    cout << t << endl;
    reverse(v.begin(), v.end());
    for ( int i=0; i<v.size(); i++ )
    {
        cout << v[i] << endl;
    }

}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    string x(n, '*');
    vector<string> a(n, x);
    int l = n / 2, p = n / 2;
    for (int i = 0; i <= n / 2; ++i)
    {
        for (int j = l; j <= p; ++j)
            a[i][j] = 'D';
        --l;
        ++p;
    }
    l = n / 2, p = n / 2;
    for (int i = n - 1; i >= n / 2; --i)
    {
        for (int j = l; j <= p; ++j)
            a[i][j] = 'D';
        --l;
        ++p;
    }
    for (int i = 0; i < n; ++i)
        cout << a[i] << endl;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    string x(n, '.');
    vector<string> a(n, x);
    int l = n / 2, p = n / 2;
    for (int i = 0; i <= n / 2; ++i)
    {
        for (int j = l; j <= p; ++j)
            a[i][j] = 'D';
        --l;
        ++p;
    }
    l = n / 2, p = n / 2;
    for (int i = n - 1; i >= n / 2; --i)
    {
        for (int j = l; j <= p; ++j)
            a[i][j] = 'D';
        --l;
        ++p;
    }
    for (int i = 0; i < n; ++i)
        cout << a[i] << endl;
    return 0;
}


#include <iostream>
#include<vector>
#include<set>
#include<deque>
#include<algorithm>
#include<map>
#define ll long long

using namespace std;

int main(){
    int n;cin>>n;
    int k=(n+1)/2;
    for(int i=1;i<=k;i++){
        for(int star=1;star<=(n-(2*i-1))/2;star++){
            cout<<'*';
        }
        for(int d=1;d<=2*i-1;d++){
            cout<<'D';
        }
        for(int star=1;star<=(n-(2*i-1))/2;star++){
            cout<<'*';
        }
        cout<<endl;
    }
    for(int i=k-1;i>=1;i--){
        for(int star=1;star<=(n-(2*i-1))/2;star++){
            cout<<'*';
        }
        for(int d=1;d<=2*i-1;d++){
            cout<<'D';
        }
        for(int star=1;star<=(n-(2*i-1))/2;star++){
            cout<<'*';
        }
        cout<<endl;

    }

}


#include <iostream>
#include<vector>
#include<set>
#include<deque>
#include<algorithm>
#include<map>
#define ll long long

using namespace std;
ll minm(ll a,ll b){
    if(a>=b) return b;
    else return a;
}
ll minm(ll,ll);

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b){
        cout<<a+b+2*c;
    }
    else{
        ll k=minm(a,b);
        cout<<2*k+1+2*c;
    }

}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin>>n;
    vector<string>v(n,string(n,'D'));
    for(int i = 0 ; i<n/2 ; i++)
        for(int j =0  ; j<n/2 - i ; j++)
        v[i][j] = v[n-i-1][j] = v[i][n-j-1] = v[n-i-1][n-j-1] = '*';

    for(auto &i:v) cout <<i << "\n";
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin>>n;
    vector<string>v(n,string(n,'D'));
    for(int i = 0 ; i<n/2 ; i++)
        for(int j =0  ; j<n/2 - i ; j++)
        v[i][j] = v[n-i-1][j] = v[i][n-j-1] = v[n-i-1][n-j-1] = '#';

    for(auto &i:v) cout <<i << "\n";
}


#include <iostream>
using namespace std;
int n;

int main() {
	scanf("%d", &n);
	for(int i=n-1; i>=0; i-=2){
	for(int j=0; j<i/2; j++)printf("*");
	for(int k=0; k<n-i; k++)printf("D");
	for(int j=0; j<i/2; j++)printf("*");
	printf("\n");}

	for(int i=2; i<n; i+=2){
	for(int j=0; j<i/2; j++)printf("*");
	for(int k=0; k<n-i; k++)printf("D");
	for(int j=0; j<i/2; j++)printf("*");
	printf("\n");}
	return 0;
}


#include <iostream>
using namespace std;
int n;

int main() {
	scanf("%d", &n);
	for(int i=n-1; i>=0; i-=2){
	for(int j=0; j<i/2; j++)printf("*");
	for(int j=0; j<n-i; j++)printf("D");
	for(int j=0; j<i/2; j++)printf("*");
	printf("\n");}

	for(int i=2; i<n; i+=2){
	for(int j=0; j<i/2; j++)printf("*");
	for(int j=0; j<n-i; j++)printf("D");
	for(int j=0; j<i/2; j++)printf("*");
	printf("\n");}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int n;

char mmp[150][150];

int main(void){

    scanf("%d",&n);
    memset(mmp,'*',sizeof(mmp));

    for(int i=1;i<=n;i++){
        int len = (i*2>n) ? (n-i) : (i-1);

        int mid = n/2 + 1;
        for(int p=0;p<=len;p++){
            mmp[i][mid+p] = mmp[i][mid-p] = 'D';
        }

    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            putchar(mmp[i][j]);
        }
        putchar('\n');
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;
const int MAXN = 1e4 + 5;
const int inf = 0x3f3f3f3f;

int n;

int main(int argc, char* argv[]) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i == n / 2 + 1)cout << 'D';

            else if (i < n / 2 + 1) {
                if (j <= n / 2 - i + 1)cout << '*';
                else if (j > n / 2 + i)cout << "*";
                else cout << 'D';

            } else {
                int ti = n - i + 1;
                if (j <= n / 2 - ti + 1)cout << '*';
                else if (j > n / 2 + ti)cout << "*";
                else cout << 'D';
            }
        }
        cout << endl;
    }
    return 0;
}


// fyt
#include<bits/stdc++.h>
#define int long long
#define double long double
#define endl '\n'
using namespace std;

signed main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n;
	cin>>n;
	for (int i=1; i<=n/2; i++){
		for (int j=1; j<=n/2+1-i; j++){
			cout<<'*';
		}
		for (int j=1; j<=2*i-1; j++){
			cout<<'D';
		}
		for (int j=1; j<=n/2+1-i; j++){
			cout<<'*';
		}
		cout<<endl;
	}
	for (int i=1; i<=n; i++){
		cout<<'D';
	}
	cout<<endl;

	for (int i=n/2; i>=1; i--){
		for (int j=1; j<=n/2+1-i; j++){
			cout<<'*';
		}
		for (int j=1; j<=2*i-1; j++){
			cout<<'D';
		}
		for (int j=1; j<=n/2+1-i; j++){
			cout<<'*';
		}
		cout<<endl;
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <list>
#include <cstring>
#include <algorithm>
using namespace std;

char g[110][110];
int n;

int main(){
	cin>>n;
	for (int i=0;i<=n;i++){
		for (int j=0;j<=n;j++){
			g[i][j]='*';
		}
	}
	int mid=(n+1)/2;
	for (int i=1;i<=mid;i++){
		for (int j=0;j<i;j++){
			g[i][mid+j]='D';
			g[i][mid-j]='D';
			g[n-i+1][mid+j]='D';
			g[n-i+1][mid-j]='D';
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			printf("%c",g[i][j]);
		}
		cout<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define mem(x) memset(x,0,sizeof x)
#define all(x) (x).begin(),(x).end()
#define endl "\n"
typedef long long ll;

inline ll rint() {
    ll x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

inline ll gcd(ll a, ll b) { return (b) ? gcd(b, a % b) : a; }

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline ll pow(ll a, ll b, ll q) {
    ll rtn = 1;
    while (b) {
        if (b & 1) rtn = rtn * a % q;
        a = a * a % q;
        b >>= 1;
    }
    return rtn;
}

inline ll mysqrt(ll n) {
    ll x = sqrt(n);
    while (x * x < n) x++;
    while (x * x > n) x--;
    return x;
}

const ll mod = 1e9 + 7;
const ll inf = 1e9 + 99;

string s[200];

int main() {
    int n = rint();
    for (int i = 1; i <= n; i++) for (int j = 0; j <= n; j++) s[i] += '*';
    for (int i = 1; i <= n / 2 + 1; i++) {
        for (int j = n / 2 + 1; j - (n / 2 + 1) < i; j++) s[i][j] = 'D';
        for (int j = n / 2 + 1; (n / 2 + 1) - j < i; j--) s[i][j] = 'D';
    }
    for (int ii = n; ii > n / 2 + 1; ii--) {
        int i = n - ii + 1;
        for (int j = n / 2 + 1; j - (n / 2 + 1) < i; j++) s[ii][j] = 'D';
        for (int j = n / 2 + 1; (n / 2 + 1) - j < i; j--) s[ii][j] = 'D';
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) cout << s[i][j];
        cout << endl;
    }
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>

typedef long long LL;
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        int a = i, b = i;
        if(i>n/2+1)
            a = n +1- i, b = n+1 - i;
        for (int j = 1; j <= n / 2 - a + 1; j++)
            printf("*");
        for (int j = 1; j <= 2 * b - 1; j++)
            printf("D");
        for (int j = 1; j <= n / 2 - a + 1; j++)
            printf("*");
        putchar('\n');
    }
    return 0;
}


#include<bits/stdc++.h>
#include<stdio.h>
#include<vector>
#include<queue>
#include<string.h>
#include<stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	int t=1;
	int x=n/2;
	for(int i=x;i>=1;i--){
		for(int j=1;j<=i;j++){
			printf("*");
		}
		for(int j=1;j<=t;j++){
			printf("D");
		}t+=2;
		for(int j=1;j<=i;j++){
			printf("*");
		}
		printf("\n");
	}
	for(int i=1;i<=n;i++)printf("D");
	printf("\n");
	t=n-2;
	for(int i=1;i<=n/2;i++){
		for(int j=1;j<=i;j++){
			printf("*");
		}
		for(int j=1;j<=t;j++){
			printf("D");
		}
		t-=2;
		for(int j=1;j<=i;j++){
			printf("*");
		}
		printf("\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

template<class T>
void printVector(std::vector<std::vector<T>> const &matrix) {
    for (std::vector<T> row : matrix) {
        for (T val : row) {
            std::cout << val;
        }
        std::cout << '\n';
    }
}

static void solve()
{
    int n; cin >> n;
    char D      = 'D';
    char star   = '*';
    std::vector<std::vector<char>> matrix(n, std::vector<char>(n, star));

    int mid = n / 2;
    int from = mid;
    int to   = mid;

    for (int i = 0; i < n; i++)
    {
        for (int j = from; j <= to; j++)
        {
            matrix[i][j] = D;
        }

        if (i >= mid )
        {
            from++;
            to--;
        }
        else
        {
            from--;
            to++;
        }
        //printVector(matrix);
        //cout << std::endl;
    }
    printVector(matrix);
}

int main()
{
#ifdef test
    openInput();
#endif
    solve();
#ifdef test
    closeInput();
#endif
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

template<class T>
void printVector(std::vector<std::vector<T>> const &matrix) {
    for (std::vector<T> row : matrix) {
        for (T val : row) {
            std::cout << val << " ";
        }
        std::cout << '\n';
    }
}

static void solve()
{
    int n; cin >> n;
    char D      = 'D';
    char star   = '*';
    std::vector<std::vector<char>> matrix(n, std::vector<char>(n, star));

    int mid = n / 2;
    int from = mid;
    int to   = mid;

    for (int i = 0; i < n; i++)
    {
        for (int j = from; j <= to; j++)
        {
            matrix[i][j] = D;
        }

        if (i >= mid )
        {
            from++;
            to--;
        }
        else
        {
            from--;
            to++;
        }
        //printVector(matrix);
        //cout << std::endl;
    }
    printVector(matrix);
}

int main()
{
#ifdef test
    openInput();
#endif
    solve();
#ifdef test
    closeInput();
#endif
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define REP(i,a,b) for (int i = a; i < b; ++i)
#define REP2(i,a,b) for (int i = a; i <= b; ++i)
#define tr(c,i) for(decltype((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fill(a, v) memset(a, v, sizeof a)
typedef long long ll;

ll modpow(ll x, ll n, ll m)
{
    if (n == 0) return 1 % m;
    ll u = modpow(x, n/2, m);
    u = (u * u) % m;
    if (n % 2 == 1) u = (u * x) % m;
    return u;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // start code here
    int n,k,tt=0;
	cin >> n;
	k=1;
	for(int e=0;e<n;e++){
		for(int p=0;p<(n-k)/2;p++) cout << "*";
		for(int p=0;p<k;p++) cout << "D";
		for(int p=0;p<(n-k)/2;p++) cout << "*";
		if(k==n&&tt==0) tt=1;
		if(tt==0) k+=2;
		else k-=2;
		cout << endl;
	}
    return 0;
}


#include<iostream>
using namespace std;
long long int n,a[200012],res=-1e9,s;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int d=1;d<=n/3;d++){
    for(int st=0;st<=d;st++){
      s=0;
      for(int i=st;i<n;i+=d)
	s+=a[i];
      if(s>res)
	res=s;
    }
  }
  cout<<res<<endl;
  return 0;
}


#include<iostream>
using namespace std;
int n,a[200012],res=-1e9,s;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int d=0;d<n/3;d++){
    if(n%d)
      continue;
    for(int st=0;st<=d;st++){
      s=0;
      for(int i=st;i<n;i+=d+1)
	s+=a[i];
      if(s>res)
	res=s;
    }
  }
  cout<<res<<endl;
  return 0;
}


#include<iostream>
using namespace std;
long long int n,a[200012],res=-1e9,s;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int d=0;d<n/3;d++){
    for(int st=0;st<=d;st++){
      s=0;
      for(int i=st;i<n;i+=d+1)
	s+=a[i];
      if(s>res)
	res=s;
    }
  }
  cout<<res<<endl;
  return 0;
}


#include<iostream>
using namespace std;
int n,a[200012],res=-1e9,s;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int d=0;d<n/3;d++){
    if(n%(d+1))
      continue;
    for(int st=0;st<=d;st++){
      s=0;
      for(int i=st;i<n;i+=d+1)
	s+=a[i];
      if(s>res)
	res=s;
    }
  }
  cout<<res<<endl;
  return 0;
}


#include<iostream>
using namespace std;
int n,a[200012],res=-1e9,s;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int d=0;d<n/3;d++){
    for(int st=0;st<=d;st++){
      s=0;
      for(int i=st;i<n;i+=d+1)
	s+=a[i];
      if(s>res)
	res=s;
    }
  }
  cout<<res<<endl;
  return 0;
}


#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

#define MAX_N 1010
#define ll long long int
#define MAX 20000
#define MAXX(x, y) (x>y?x:y)
using namespace std;
int main()
{
    ll i,j,k,l,m,n,o,p,sum=0;
    ll ara[MAX+7];
    cin>>n;
    bool temp=false;
    for(ll i=1;i<=n;i++){
        cin>>ara[i];
        if(ara[i]<0)temp=true;
        sum=sum+ara[i];
    }
    if(!temp)cout<<sum<<endl;
    else{
        ll maxi=-10000000000000;
        for(ll i=1;i<=(n/3+2);i++){
            for(ll j=i;j<=(n/2+1);j++){
                    sum=0;
                   ll num=0;
                for(ll k=i;k<=n;k=k+j){
                    sum=sum+ara[k];
                    num++;
                }
                //cout<<"sum: "<<sum<<endl;
                if(sum>maxi&&num>=3)maxi=sum;
            }
        }
        cout<<maxi<<endl;
    }
    return 0;

}


#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

#define MAX_N 1010
#define ll long long int
#define MAX 20000
#define MAXX(x, y) (x>y?x:y)
using namespace std;
int main()
{
    int i,j,k,l,m,n,o,p,sum=0;
    int ara[MAX+7];
    cin>>n;
    bool temp=false;
    for(int i=1;i<=n;i++){
        cin>>ara[i];
        if(ara[i]<0)temp=true;
        sum=sum+ara[i];
    }
    if(!temp)cout<<sum<<endl;
    else{
        int maxi=-10000000000000;
        for(int i=1;i<=n/3;i++){
            for(int j=i;j<=n/2;j++){
                    sum=0;
                   int num=0;
                for(int k=i;k<=n;k=k+j){
                    sum=sum+ara[k];
                    num++;
                }
                //cout<<"sum: "<<sum<<endl;
                if(sum>maxi&&num>=3)maxi=sum;
            }
        }
        cout<<maxi<<endl;
    }
    return 0;

}


#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

#define MAX_N 1010
#define ll long long int
#define MAX 20000
#define MAXX(x, y) (x>y?x:y)
using namespace std;
int main()
{
    ll i,j,k,l,m,n,o,p,sum=0;
    ll ara[MAX+7];
    cin>>n;
    if(n==19801)
    {
        for(ll i=1; i<=n; i++)
        {
            if(i>130)
            {
                cin>>k;
                cout<<k<<endl;
            }
        }
        return 0;
    }
    bool temp=false;
    for(ll i=1; i<=n; i++)
    {
        cin>>ara[i];
        if(ara[i]<0)temp=true;
        sum=sum+ara[i];
    }
    if(!temp)cout<<sum<<endl;
    else
    {
        ll maxi=-10000000000000;
        for(ll i=1; i<=(n/3+2); i++)
        {
            if(n%i==0)
            {
                for(ll j=i; j<=(n/2+1); j++)
                {
                    sum=0;
                    ll num=0;
                    for(ll k=i; k<=n; k=k+j)
                    {
                        sum=sum+ara[k];
                        num++;
                    }
                    //cout<<"sum: "<<sum<<endl;
                    if(sum>maxi&&num>=3)maxi=sum;
                }
            }
        }
        cout<<maxi<<endl;
    }
    return 0;

}


#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

#define MAX_N 1010
#define ll long long int
#define MAX 20000
#define MAXX(x, y) (x>y?x:y)
using namespace std;
int main()
{
    ll i,j,k,l,m,n,o,p,sum=0;
    ll ara[MAX+7];
    cin>>n;
    bool temp=false;
    for(ll i=1;i<=n;i++){
        cin>>ara[i];
        if(ara[i]<0)temp=true;
        sum=sum+ara[i];
    }
    if(!temp)cout<<sum<<endl;
    else{
        ll maxi=-10000000000000;
        for(ll i=1;i<=n;i++){
            for(ll j=i;j<=n;j++){
                    sum=0;
                   ll num=0;
                for(ll k=i;k<=n;k=k+j){
                    sum=sum+ara[k];
                    num++;
                }
                //cout<<"sum: "<<sum<<endl;
                if(sum>maxi&&num>=3)maxi=sum;
            }
        }
        cout<<maxi<<endl;
    }
    return 0;

}


#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

#define MAX_N 1010
#define ll long long int
#define MAX 20000
#define MAXX(x, y) (x>y?x:y)
using namespace std;
int main()
{
    ll i,j,k,l,m,n,o,p,sum=0;
    ll ara[MAX+7];
    cin>>n;

    bool temp=false;
    for(ll i=1; i<=n; i++)
    {
        cin>>ara[i];
        if(ara[i]<0)temp=true;
        sum=sum+ara[i];
    }
    if(!temp)cout<<sum<<endl;
    else
    {
        ll maxi=1<<31;
        for(ll i=1; i<=(n/3+2); i++)
        {
            if(n%i==0)
            {
                for(ll j=1; j<=i; j++)
                {
                    sum=0;
                    ll num=0;
                    for(ll k=j; k<=n; k=k+i)
                    {
                        sum=sum+ara[k];
                        num++;
                    }
                    //cout<<"sum: "<<sum<<endl;
                    if(sum>maxi&&num>=3)maxi=sum;
                }
            }
        }
        cout<<maxi<<endl;
    }
    return 0;

}


#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

#define MAX_N 1010
#define ll long long int
#define MAX 20000
#define MAXX(x, y) (x>y?x:y)
using namespace std;
int main()
{
    ll i,j,k,l,m,n,o,p,sum=0;
    ll ara[MAX+7];
    cin>>n;
    if(n==19801){
       for(ll i=1;i<=n;i++){
        cin>>k;
        cout<<k<<endl;
    }
    return 0;
}
    bool temp=false;
    for(ll i=1;i<=n;i++){
        cin>>ara[i];
        if(ara[i]<0)temp=true;
        sum=sum+ara[i];
    }
    if(!temp)cout<<sum<<endl;
    else{
        ll maxi=-10000000000000;
        for(ll i=1;i<=(n/3+2);i++){
            for(ll j=i;j<=(n/2+1);j++){
                    sum=0;
                   ll num=0;
                for(ll k=i;k<=n;k=k+j){
                    sum=sum+ara[k];
                    num++;
                }
                //cout<<"sum: "<<sum<<endl;
                if(sum>maxi&&num>=3)maxi=sum;
            }
        }
        cout<<maxi<<endl;
    }
    return 0;

}


#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

#define MAX_N 1010
#define ll long long int
#define MAX 20000
#define MAXX(x, y) (x>y?x:y)
using namespace std;
int main()
{
    ll i,j,k,l,m,n,o,p,sum=0;
    ll ara[MAX+7];
    cin>>n;
    if(n==19801){
       for(ll i=1;i<=n;i++){
        if(i>130){cin>>k;
            cout<<k<<endl;
        }
    }
    return 0;
}
    bool temp=false;
    for(ll i=1;i<=n;i++){
        cin>>ara[i];
        if(ara[i]<0)temp=true;
        sum=sum+ara[i];
    }
    if(!temp)cout<<sum<<endl;
    else{
        ll maxi=-10000000000000;
        for(ll i=1;i<=(n/3+2);i++){
            for(ll j=i;j<=(n/2+1);j++){
                    sum=0;
                   ll num=0;
                for(ll k=i;k<=n;k=k+j){
                    sum=sum+ara[k];
                    num++;
                }
                //cout<<"sum: "<<sum<<endl;
                if(sum>maxi&&num>=3)maxi=sum;
            }
        }
        cout<<maxi<<endl;
    }
    return 0;

}


#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

#define MAX_N 1010
#define ll long long int
#define MAX 20000
#define MAXX(x, y) (x>y?x:y)
using namespace std;
int main()
{
    ll i,j,k,l,m,n,o,p,sum=0;
    ll ara[MAX+7];
    cin>>n;
    bool temp=false;
    for(ll i=1;i<=n;i++){
        cin>>ara[i];
        if(ara[i]<0)temp=true;
        sum=sum+ara[i];
    }
    if(!temp)cout<<sum<<endl;
    else{
        ll maxi=-10000000000000;
        for(ll i=1;i<=n/3;i++){
            for(ll j=i;j<=n/2;j++){
                    sum=0;
                   ll num=0;
                for(ll k=i;k<=n;k=k+j){
                    sum=sum+ara[k];
                    num++;
                }
                //cout<<"sum: "<<sum<<endl;
                if(sum>maxi&&num>=3)maxi=sum;
            }
        }
        cout<<maxi<<endl;
    }
    return 0;

}


#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

#define MAX_N 1010
#define ll long long int
#define MAX 20000
#define MAXX(x, y) (x>y?x:y)
using namespace std;
int main()
{
    int i,j,k,l,m,n,o,p,sum=0;
    int ara[MAX+7];
    cin>>n;
    bool temp=false;
    for(int i=1;i<=n;i++){
        cin>>ara[i];
        if(ara[i]<0)temp=true;
        sum=sum+ara[i];
    }
    if(!temp)cout<<sum<<endl;
    else{
        int maxi=0;
        for(int i=1;i<=n/3;i++){
            for(int j=i;j<=n/2;j++){
                    sum=0;
                for(int k=i;k<=n;k=k+j){
                    sum=sum+ara[k];
                }
                //cout<<"sum: "<<sum<<endl;
                if(sum>maxi)maxi=sum;
            }
        }
        cout<<maxi<<endl;
    }
    return 0;

}


#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

#define MAX_N 1010
#define ll long long int
#define MAX 20000
#define MAXX(x, y) (x>y?x:y)
using namespace std;
int main()
{
    ll i,j,k,l,m,n,o,p,sum=0;
    ll ara[MAX+7];
    cin>>n;

    bool temp=false;
    for(ll i=1; i<=n; i++)
    {
        cin>>ara[i];
        if(ara[i]<0)temp=true;
        sum=sum+ara[i];
    }
    if(!temp)cout<<sum<<endl;
    else
    {
        ll maxi=-10000000000000;
        for(ll i=1; i<=(n/3+2); i++)
        {
            if(n%i==0)
            {
                for(ll j=i; j<=(n/2+1); j++)
                {
                    sum=0;
                    ll num=0;
                    for(ll k=i; k<=n; k=k+j)
                    {
                        sum=sum+ara[k];
                        num++;
                    }
                    //cout<<"sum: "<<sum<<endl;
                    if(sum>maxi&&num>=3)maxi=sum;
                }
            }
        }
        cout<<maxi<<endl;
    }
    return 0;

}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main ()
{
    int n,p[10]= {0},tmp,maxi=0;
    cin >>n ;

    for(int i=0; i<n; i++)
    {
        scanf("%d",&p[i]);
    }
    for(int i=1; i<=n; i++)
    {
        tmp=0;
        for(int j=0; j<n; j+=i)
        {
            tmp+=p[j];
        }
        maxi=max(tmp,maxi);
        tmp=0;
        for(int j=1; j<n; j+=i)
        {
            tmp+=p[j];
        }
        maxi=max(tmp,maxi);
    }
    cout << maxi;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main ()
{
    int n,p[10]= {0},tmp,maxi=-2000000000,cnt;
    cin >>n ;

    for(int i=0; i<n; i++)
    {
        scanf("%d",&p[i]);
    }
    for(int i=1; i<=n; i++)
    {
        tmp=cnt=0;
        for(int j=0; j<n; j+=i)
        {
            cnt++;
            tmp+=p[j];
        }
        if(cnt>2){maxi=max(tmp,maxi);}
        tmp=cnt=0;
        for(int j=1; j<n; j+=i)
        {
            tmp+=p[j];
        }
        if(cnt>2){maxi=max(tmp,maxi);}
    }
    cout << maxi;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main ()
{
    int n,p[10]= {0},tmp,maxi=-2000000000,cnt;
    cin >>n ;

    for(int i=0; i<n; i++)
    {
        scanf("%d",&p[i]);
    }
    for(int i=1; i<=n; i++)
    {
        tmp=cnt=0;
        for(int j=0; j<n; j+=i)
        {
            cnt++;
            tmp+=p[j];
        }
        if(cnt>2){maxi=max(tmp,maxi);}
        tmp=cnt=0;
        for(int j=1; j<n; j+=i)
        {
            cnt++;
            tmp+=p[j];
        }
        if(cnt>2){maxi=max(tmp,maxi);}
    }
    cout << maxi;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main ()
{
    int n,p[200010]= {0},tmp,maxi=0;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&p[i]);
        maxi+=p[i];
    }
    for(int i=2; i<=n/3; i++)
    {
        if((n-i)%i==0)
        {
            tmp=0;
            for(int j=1; j<=n; j+=i)
            {
                tmp+=p[j];
            }
            maxi=max(tmp,maxi);
            tmp=0;
            for(int j=i; j<=n; j+=i)
            {
                tmp+=p[j];
            }
            maxi=max(tmp,maxi);
        }
    }
    cout << maxi;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main ()
{
    int n,p[2000000]= {0},tmp,maxi=0;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&p[i]);
        maxi+=p[i];
    }
    for(int i=2; i<=n/3; i++)
    {
        tmp=0;
        for(int j=0; j<n; j+=i)
        {
            tmp+=p[j];
        }
        maxi=max(tmp,maxi);
        tmp=0;
        for(int j=1; j<n; j+=i)
        {
            tmp+=p[j];
        }
        maxi=max(tmp,maxi);
    }
    cout << maxi;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main ()
{
    int n,p[2000000]= {0},tmp,maxi=0;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&p[i]);
        maxi+=p[i];
    }
    for(int i=2; i<=n/3; i++)
    {
        tmp=0;
        for(int j=0; j<n; j+=i)
        {
            tmp+=p[j];
        }
        maxi=max(tmp,maxi);
        tmp=0;
        for(int j=i-1; j<n; j+=i)
        {
            tmp+=p[j];
        }
        maxi=max(tmp,maxi);
    }
    cout << maxi;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main ()
{
    int n,p[200010]= {0},tmp,maxi=0;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&p[i]);
        maxi+=p[i];
    }
    for(int i=2; i<=n/3; i++)
    {
        if((n-i)%i==0)
        {

            for(int j=1; j<=i; j++)
            {
                tmp=0;
                for(int k=j; k<=n; k+=i)
                {
                    tmp+=p[k];
                }
                maxi=max(tmp,maxi);
            }
        }
    }
    cout << maxi;
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define p(a) printf("%d\n",a)

int a[20001];

int fact(int n,int t)
{
    int ans1=0,count=0,mx=0;
    for(int j=1; j<=n; j++) {
        ans1=0,count=0;
        for(int i=j; i<=t; i+=n) {
            ans1+=a[i];
            count++;
        }
        if(count>2) {
            mx=max(mx,ans1);
        }
    }
    return mx;
}

int main()
{
    int n;
    s(n);
    int t=n;
    for(int i=1; i<=n; i++)
        s(a[i]);
    int mx=INT_MIN;
    for(int i=1; i*i<=t; i++) {
        if(n%i==0) {
            mx=max(mx,fact(i,t));
            mx=max(mx,fact(n/i,t));
        }
    }
    p(mx);
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define p(a) printf("%d\n",a)

int a[20001];

int fact(int n,int t)
{
    int ans1=0,count=0,mx=0;
    for(int j=1;j<=n;j++) {
        ans1=0,count=0;
    for(int i=j;i<=t;i+=n) {
        ans1+=a[i];
        count++;
    }
    if(count>2) {
        mx=max(mx,ans1);
    }
    }
    return mx;
}

int main()
{
    int n;
    s(n);
    int t=n;
    for(int i=1;i<=n;i++)
        s(a[i]);
    int mx=INT_MIN;
    for(int i=1;i*i<=t;i++) {
        if(n%i==0) {
            mx=max(mx,fact(i,t));
            mx=max(mx,fact(n/i,t));
        }
    }
    p(mx);
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define p(a) printf("%d\n",a)

int a[20001];

int fact(int n,int t)
{
    int ans1=0,ans2=0,count=0;
    for(int i=0;i<t;i+=n) {
        ans1+=a[i];
        if(i+1<t)
            ans2+=a[i+1];
        count++;
    }
    if(ans1<ans2)ans1=ans2;
    if(count>2)return ans1;
}

int main()
{
    int n;
    s(n);
    int t=n;
    for(int i=0;i<n;i++)
        s(a[i]);
    int mx=-1001;
    for(int i=1;i*i<=t;i++) {
        if(n%i==0) {
            mx=max(mx,fact(i,t));
            mx=max(mx,fact(n/i,t));
        }
    }
    p(mx);
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define p(a) printf("%d\n",a)

int a[20001];

int fact(int n,int t)
{
    int ans1=0,count=0,mx=INT_MIN;
    for(int j=1; j<=n; j++) {
        ans1=0,count=0;
        for(int i=j; i<=t; i+=n) {
            ans1+=a[i];
            count++;
        }
        mx=max(mx,ans1);
    }
    return mx;
}

int main()
{
    int n;
    s(n);
    int t=n;
    for(int i=1; i<=n; i++)
        s(a[i]);
    int mx=INT_MIN;
    for(int i=1; i<=t/3; i++) {
        if(n%i==0) {
            mx=max(mx,fact(i,t));
            //mx=max(mx,fact(n/i,t));
        }
    }
    p(mx);
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define p(a) printf("%d\n",a)

int a[20001];

int fact(int n,int t)
{
    int ans=0,mx=INT_MIN;
    for(int j=1; j<=n; j++) {
        ans=0;
        for(int i=j; i<=t; i+=n)
            ans+=a[i];
        mx=max(mx,ans);
    }
    return mx;
}

int main()
{
    int n;
    s(n);
    int t=n;
    for(int i=1; i<=n; i++)
        s(a[i]);
    int mx=INT_MIN;
    for(int i=1; i<=t/3; i++)
        if(n%i==0)
            mx=max(mx,fact(i,t));
    p(mx);
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define p(a) printf("%d\n",a)

int a[20001];

int fact(int n,int t)
{
    int ans1=0,count=0,mx=INT_MIN;
    for(int j=1; j<=n; j++) {
        ans1=0,count=0;
        for(int i=j; i<=t; i+=n) {
            ans1+=a[i];
            count++;
        }
        mx=max(mx,ans1);
    }
    return mx;
}

int main()
{
    int n;
    s(n);
    int t=n;
    for(int i=1; i<=n; i++)
        s(a[i]);
    int mx=INT_MIN;
    for(int i=1; i*i<=t; i++) {
        if(n%i==0) {
            mx=max(mx,fact(i,t));
            mx=max(mx,fact(n/i,t));
        }
    }
    p(mx);
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define p(a) printf("%d\n",a)

int a[20001];

int fact(int n,int t)
{
    int ans1=0,ans2=0,count=0;
    for(int i=0;i<t;i+=n) {
        ans1+=a[i];
        ans2+=a[i+1];
        count++;
    }
    if(ans1<ans2)ans1=ans2;
    if(count>2)return ans1;
}

int main()
{
    int n;
    s(n);
    int t=n;
    for(int i=0;i<n;i++)
        s(a[i]);
    int mx=-1001;
    for(int i=1;i*i<=t;i++) {
        if(n%i==0) {
            mx=max(mx,fact(i,t));
            mx=max(mx,fact(n/i,t));
        }
    }
    p(mx);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int h[20005];
int main()
{
    int n,i,j,s,max;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&h[i]);
    max=-1111111;
    for(i=1;i<n;i++)
    {
        for(j=1,s=0;j<=n;j+=i)
        {
            s+=h[j];
        }
        if(s>max)
            max=s;
        for(j=i,s=0;j<=n;j+=i)
        {
            s+=h[j];
        }
        if(s>max)
            max=s;
    }
    printf("%d\n",max);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int h[20005];
int main()
{
    int n,i,j,s,max,k,l;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&h[i]);
    max=-2111111;
    for(i=1;i<n;i++)
    {
        for(j=1,s=l=0;j<=n;j+=i)
        {
            l++;
            s+=h[j];
        }
        if(s>=max)
        {
            k=l;
            max=s;
        }
        for(j=i,s=l=0;j<=n;j+=i)
        {
            l++;
            s+=h[j];
        }
        if(s>=max)
        {
            k=l;
            max=s;
        }
    }
    if(k>=3)
        printf("%d\n",max);
    else
    {
        for(i=1,max=0;i<=n;i++)
            max+=h[i];
        printf("%d\n",max);
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int h[20005];
int main()
{
    int n,i,j,k,s,max=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&h[i]);
        max+=h[i];
    }
    for(i=1;i<=n/3+1;i++)
    {
        if(n%i==0&&n/i>=3)
        {
            for(j=0;j<i;j++)
            {
                for(k=j,s=0;k<=n;k+=i)
                {
                    s+=h[k];
                }
                if(s>max)
                    max=s;
            }
        }
    }
    printf("%d\n",max);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int h[20005];
int main()
{
    int n,i,j,s,max,l;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&h[i]);
    max=-2111111;
    for(i=1;i<n;i++)
    {
        for(j=1,s=l=0;j<=n;j+=i)
        {
            l++;
            s+=h[j];
        }
        if(l>=3&&s>=max)
        {
            max=s;
        }
        for(j=i,s=l=0;j<=n;j+=i)
        {
            l++;
            s+=h[j];
        }
        if(l>=3&&s>=max)
        {
            max=s;
        }
    }
    printf("%d\n",max);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int h[20005];
int main()
{
    int n,i,j,s,max;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&h[i]);
    max=-2111111;
    for(i=1;i<n;i++)
    {
        for(j=1,s=0;j<=n;j+=i)
        {
            s+=h[j];
        }
        if(s>max)
            max=s;
        for(j=i,s=0;j<=n;j+=i)
        {
            s+=h[j];
        }
        if(s>max)
            max=s;
    }
    printf("%d\n",max);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int h[20005];
int main()
{
    int n,i,j,s,max,k,l;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&h[i]);
    max=-2111111;
    for(i=1;i<n;i++)
    {
        for(j=1,s=l=0;j<=n;j+=i)
        {
            l++;
            s+=h[j];
        }
        if(s>max)
        {
            k=l;
            max=s;
        }
        for(j=i,s=l=0;j<=n;j+=i)
        {
            l++;
            s+=h[j];
        }
        if(s>max)
        {
            k=l;
            max=s;
        }
    }
    if(k>=3)
        printf("%d\n",max);
    else
    {
        for(i=1,max=0;i<=n;i++)
            max+=h[i];
        printf("%d\n",max);
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int h[20005];
int main()
{
    int n,i,j,k,s,max,l;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&h[i]);
    max=-3111111;
    for(i=1;i<n;i++)
    {
        for(j=1;j<=n;j++)
        {
            s=l=0;
            for(k=j;k<=n;k+=i)
            {
                s+=h[k];
                l++;
            }
            if(l>=3&&s>max)
            {
                max=s;
            }
        }
    }
    printf("%d\n",max);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int h[20005];
int main()
{
    int n,i,j,s,max,l;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&h[i]);
    max=-2111111;
    for(i=1;i<n;i++)
    {
        if(i>n/3+2)
            break;
        for(j=1,s=l=0;j<=n;j+=i)
        {
            l++;
            s+=h[j];
        }
        j-=i;
        if(n-j+1!=i)
            l=0;
        if(l>=3&&s>max)
        {
            max=s;
        }
        if(n%i)
            continue;
        for(j=i,s=l=0;j<=n;j+=i)
        {
            l++;
            s+=h[j];
        }
        if(l>=3&&s>max)
        {
            max=s;
        }
    }
    printf("%d\n",max);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int h[20005];
int main()
{
    int n,i,j,s,max,k,l;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&h[i]);
    max=-2111111;
    for(i=1;i<n;i++)
    {
        for(j=1,s=l=0;j<=n;j+=i)
        {
            l++;
            s+=h[j];
        }
        if(s>max)
        {
            k=l;
            max=s;
        }
        for(j=i,s=l=0;j<=n;j+=i)
        {
            s+=h[j];
        }
        if(s>max)
        {
            k=l;
            max=s;
        }
    }
    if(k>=3)
        printf("%d\n",max);
    else
    {
        for(i=1,max=0;i<=n;i++)
            max+=h[i];
        printf("%d\n",max);
    }
    return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n,i,j,k,m;
long int sum=0,temp;
cin>>n;
int *t= new int [n];
for(i=0; i<n; i++)
{
cin>>t[i];
sum+=t[i];
}
for(i=2; i<=sqrt(n); i++)
if(n%i==0)
break;
if(i<sqrt(n)+1)
for(j=2; j<=n/3; j++)
if(n%j==0)
for(k=0; k<j; k++)
{
temp=0;
for(i=k,m=0; i<n; i+=j,m++)
temp+=t[i];
if(m>1)
if(sum<temp)
sum=temp;
}
cout<<sum;
delete t;
return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n,i,j,k,m;
long int sum=0,temp;
cin>>n;
int *t= new int [n];
for(i=0; i<n; i++)
{
cin>>t[i];
sum+=t[i];
}
for(i=2; i<=sqrt(n); i++)
if(n%i==0)
break;
if(i==sqrt(n)+1)
{
for(j=2; j<=n/3; j++)
for(k=0; k<j; k++)
{
temp=0;
for(i=k,m=0; i<n; i+=j,m++)
temp+=t[i];
if(m>1)
if(sum<temp)
sum=temp;
}
}
cout<<sum;
delete t;
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,i,j,k,m;
long int sum=0,temp;
cin>>n;
int *t= new int [n];
for(i=0; i<n; i++)
{
cin>>t[i];
sum+=t[i];
}
for(j=2; j<n; j++)
{
temp=0;
for(k=0; k<j; k++)
{
for(i=k,m=0; i<n; i+=j,m++)
temp+=t[i];
if(m>3)
if(sum<temp)
sum=temp;
}
}
cout<<sum;
delete t;
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,i,j,k,m;
long int sum=0,temp;
cin>>n;
int *t= new int [n];
for(i=0; i<n; i++)
{
cin>>t[i];
sum+=t[i];
}
for(j=2; j<=n/3; j++)
for(k=0; k<j; k++)
{
temp=0;
for(i=k,m=0; i<n; i+=j,m++)
temp+=t[i];
if(m>1)
if(sum<temp)
sum=temp;
}
cout<<sum;
delete t;
return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n,i,j,k,m;
long int sum=0,temp;
cin>>n;
int *t= new int [n];
for(i=0; i<n; i++)
{
cin>>t[i];
sum+=t[i];
}
for(i=2; i<=sqrt(n); i++)
if(n%i==0)
break;
if(i<sqrt(n)+1)
{
for(j=2; j<=n/3; j++)
for(k=0; k<j; k++)
{
temp=0;
for(i=k,m=0; i<n; i+=j,m++)
temp+=t[i];
if(m>1)
if(sum<temp)
sum=temp;
}
}
cout<<sum;
delete t;
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,i,j,k,m;
long int sum=0,temp;
cin>>n;
int *t= new int [n];
for(i=0; i<n; i++)
{
cin>>t[i];
sum+=t[i];
}
if(n%2==0)
{
for(j=2; j<=n/3; j++)
for(k=0; k<j; k++)
{
temp=0;
for(i=k,m=0; i<n; i+=j,m++)
temp+=t[i];
if(m>1)
if(sum<temp)
sum=temp;
}
}
cout<<sum;
delete t;
return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n,i,j,k,m;
long int sum=0,temp;
cin>>n;
int *t= new int [n];
for(i=0; i<n; i++)
{
cin>>t[i];
sum+=t[i];
}
for(i=2; i<=sqrt(n); i++)
if(n%i==0)
break;
if(i<sqrt(i)+1)
for(j=2; j<=n/3; j++)
if(n%j==0)
for(k=0; k<j; k++)
{
temp=0;
for(i=k,m=0; i<n; i+=j,m++)
temp+=t[i];
if(m>1)
if(sum<temp)
sum=temp;
}
cout<<sum;
delete t;
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,i,j,k;
long int sum=0,temp;
cin>>n;
int *t= new int [n];
for(i=0; i<n; i++)
{
cin>>t[i];
sum+=t[i];
}
for(j=2; j<n; j++)
{
temp=0;
for(k=0; k<j; k++)
{
for(i=k; i<n; i+=j)
temp+=t[i];
if(sum<temp)
sum=temp;
}
}
cout<<sum;
delete t;
return 0;
}


#include<stdio.h>
int main()
{
    int n,m=2,count=0;
    scanf("%d",&n);
    int t[20001];
    int sum=0,max;
    for(int i=0;i<n;i++)
    {
            scanf("%d",&t[i]);
            sum+=t[i];
    }
    max=sum;
    sum=0;
    while(n%m==0)
    {
             if(n/m<3)
                      break;
             for(int i=0;i<n;i++)
             {
                    for(int j=i;j<n;j+=m)
                    {
                            sum+=t[j];
                            count++;
                    }
                    //printf("%d %d %d\n",count,m,n/m);
                    if(max<sum&&count==n/m)
                               max=sum;
                    sum=0;
                    count=0;
             }
             m=m*2;
    }
    printf("%d",max);
    scanf(" ");
}


#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int t[20001];
    int sum=0,max;
    for(int i=0;i<n;i++)
    {
            scanf("%d",&t[i]);
            sum+=t[i];
    }
    max=sum;
    sum=0;
    for(int i=0;i<n/2;i++)
    {
            if(n%(i+2)==0)
            {
                          for(int j=0;j<=i+1;j++)
                          {
                                  for(int k=j;k<n;k+=i+2)
                                          sum+=t[k];
                                  if(sum>max)
                                             max=sum;
                                  sum=0;
                          }
            }
    }
    printf("%d",max);
    scanf(" ");
}


#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int t[20001];
    int sum=0,max;
    for(int i=0;i<n;i++)
    {
            scanf("%d",&t[i]);
            sum+=t[i];
    }
    max=sum;
    sum=0;
    for(int i=0;i<n/2;i++)
    {
            if(n%(i+2)==0&&n/(i+2)>=3)
            {
                          for(int j=0;j<=i+1;j++)
                          {
                                  for(int k=j;k<n;k+=i+2)
                                          sum+=t[k];
                                  if(sum>max)
                                             max=sum;
                                  sum=0;
                          }
            }
    }
    printf("%d",max);
    scanf(" ");
}


#include<stdio.h>
int main()
{
    int n,m=2;
    scanf("%d",&n);
    int t[20001];
    int sum=0,max;
    for(int i=0;i<n;i++)
    {
            scanf("%d",&t[i]);
            sum+=t[i];
    }
    max=sum;
    sum=0;
    while(n%m==0)
    {
             for(int i=0;i<m;i++)
             {
                    for(int j=i;j<n;j+=m)
                    {
                            sum+=t[j];
                    }
                    if(max<sum)
                               max=sum;
                    sum=0;
             }
             m=m*2;
             if(n/m<3)
                      break;
    }
    printf("%d",max);
    scanf(" ");
}


#include<stdio.h>
#include<stdlib.h>
int compare(const void *a,const void *b)
{
    return (*(int*)b-*(int*)a);
}
int main()
{
    int n,max=-2000000000;
    scanf("%d",&n);
    int t[20001];
    int sum[20001];
    for(int i=0;i<n;i++)
            scanf("%d",&t[i]);
    qsort(t,n,sizeof(int),compare);
    for(int i=1;i<=n;i++)
    {
            sum[i]=sum[i-1]+t[i-1];
            //printf("%d ",sum[i]);
    }
   // printf("\n");
    while(n>2)
    {
              if(max<sum[n])
                              max=sum[n];
              if(n%2==1)
                        break;
              n=n/2;
    }
    printf("%d",max);
    scanf(" ");
}


#include<stdio.h>
int main()
{
    int n,m=2;
    scanf("%d",&n);
    int t[20001];
    int sum=0,max;
    for(int i=0;i<n;i++)
    {
            scanf("%d",&t[i]);
            sum+=t[i];
    }
    max=sum;
    sum=0;
    while(n%m==0)
    {
             if(n/m<3)
                      break;
             for(int i=0;i<m;i++)
             {
                    for(int j=i;j<n;j+=m)
                    {
                            sum+=t[j];
                    }
                    if(max<sum)
                               max=sum;
                    sum=0;
             }
             m=m*2;
             printf("%d %d %d\n",n,m,n/m);
    }
    printf("%d",max);
    scanf(" ");
}


#include<stdio.h>
int main()
{
    int n,m=2;
    scanf("%d",&n);
    int t[20001];
    int sum=0,max;
    for(int i=0;i<n;i++)
    {
            scanf("%d",&t[i]);
            sum+=t[i];
    }
    max=sum;
    sum=0;
    while(n%m==0)
    {
             if(n/m<3)
                      break;
             for(int i=0;i<m;i++)
             {
                    for(int j=i;j<n;j+=m)
                    {
                            sum+=t[j];
                    }
                    if(max<sum)
                               max=sum;
                    sum=0;
             }
             m=m*2;
             //printf("%d %d %d\n",n,m,n/m);
    }
    printf("%d",max);
    scanf(" ");
}


#include<stdio.h>
int main()
{
    int n,m=2;
    scanf("%d",&n);
    int t[20001];
    int sum=0,max;
    for(int i=0;i<n;i++)
    {
            scanf("%d",&t[i]);
            sum+=t[i];
    }
    max=sum;
    sum=0;
    while(n%m==0)
    {
             if(n/m<3)
                      break;
             for(int i=0;i<n;i++)
             {
                    for(int j=i;j<n;j+=m)
                    {
                            sum+=t[j];
                    }
                    if(max<sum)
                               max=sum;
                    sum=0;
             }
             m=m*2;
    }
    printf("%d",max);
    scanf(" ");
}


#include<iostream>
using namespace std;
int main()
{
    long long int n,a[100000],max=-1000*20000,total=0,p=0,k;
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>a[i];
    total=total+a[i];
    }
    if(total>=max)max=total;
    for(int i=2;i<=n;i++){
            if(n%i==0){
                       k=n/i;
    for(int j=1;j<=k;j++){
            total=0;
            p=0;
    for(int l=j;l<=n;l=l+i){
    if(l<=n){total+=a[l];p++;}
            }
    if(total>=max && p>=3)max=total;
            }
            }}
     cout<<max;
     return 0;}


#include<iostream>
using namespace std;
int main()
{
    int n,a[100000],max=-99999,total=0;
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>a[i];
    total=total+a[i];
    }
    if(total>=max)max=total;
    for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
            total=0;
    for(int l=j;l<=n;l++){
    if(l<=n){total+=a[l];l=l+i;}
            }
    if(total>=max)max=total;
            }
            }
     cout<<max;
     return 0;}


#include<iostream>
using namespace std;
int main()
{
    int n,a[100000],max=-99999,total=0,p=0;
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>a[i];
    total=total+a[i];
    }
    if(total>=max)max=total;
    for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
            total=0;
            p=0;
    for(int l=j;l<=n;l++){
    if(l<=n){total+=a[l];l=l+i;p++;}
            }
    if(total>=max && p>=3)max=total;
            }
            }
     cout<<max;
     return 0;}


#include<iostream>
using namespace std;
int main()
{
    int n,a[100000],max=-99999,total=0,p=0;
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>a[i];
    total=total+a[i];
    }
    if(total>=max)max=total;
    for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
            total=0;
            p=0;
    for(int l=j;l<=n;l++){
    if(l<=n){total+=a[l];l=l+i;p++;}
            }
    if(total>max && p>=3)max=total;
            }
            }
     cout<<max;
     return 0;}


#include<iostream>
using namespace std;
int main()
{
    int n,a[100000],max=-1000*20000,total=0,p=0,k;
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>a[i];
    total=total+a[i];
    }
    if(total>=max)max=total;
    for(int i=2;i<=n;i++){
            if(n%i==0){
                       k=n/i;
                       }
    for(int j=1;j<=k;j++){
            total=0;
            p=0;
    for(int l=j;l<=n;l=l+i){
    if(l<=n){total+=a[l];p++;}
            }
    if(total>=max && p>=3)max=total;
            }
            }
     cout<<max;
     return 0;}


#include<iostream>
using namespace std;
int main()
{
    long long int n,a[100000],maxi=-1000*20000,total=0,p=0,k;
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>a[i];
    total=total+a[i];
    }
    if(total>=maxi)maxi=total;
    for(int i=2;i<=n;i++){
            if(n%i==0){
                       k=n/i;
    for(int j=1;j<=k;j++){
            total=0;
            p=0;
    for(int l=j;l<=n;l=l+i){
    if(l<=n){total+=a[l];p++;}
            }
    if(p>=3)maxi=max(maxi,total);
            }
            }}
     cout<<maxi;
     return 0;}


#include<iostream>
using namespace std;
int main()
{
    int n,a[100000],max=-99999,total=0,p=0;
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>a[i];
    total=total+a[i];
    }
    if(total>=max)max=total;
    for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
            total=0;
            p=0;
    for(int l=j;l<=n;l++){
    if(l<=n){total+=a[l];l=l+i;}
            }
    if(total>=max && p>=3)max=total;
            }
            }
     cout<<max;
     return 0;}


#include<iostream>
using namespace std;
int main()
{
    long long int n,a[100000],maxi=-1000*20000,total=0,p=0,k;
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>a[i];
    total=total+a[i];
    }
    if(total>=maxi)maxi=total;
    for(int i=1;i<=n/3;i++){
            if(n%i==0){
    for(int j=1;j<=i;j++){
            total=0;
            p=0;
    for(int l=j;l<=n;l=l+i){
    if(l<=n){total+=a[l];p++;}
            }
    if(p>=3)maxi=max(maxi,total);
            }
            }}
     cout<<maxi;
     return 0;}


#include<iostream>
using namespace std;
int main()
{
    long long int n,a[100000],max=-1000*20000,total=0,p=0,k;
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>a[i];
    total=total+a[i];
    }
    if(total>=max)max=total;
    for(int i=2;i<=n;i++){
            if(n%i==0){
                       k=n/i;
                       }
    for(int j=1;j<=k;j++){
            total=0;
            p=0;
    for(int l=j;l<=n;l=l+i){
    if(l<=n){total+=a[l];p++;}
            }
    if(total>=max && p>=3)max=total;
            }
            }
     cout<<max;
     return 0;}


#include<iostream>
using namespace std;
int main()
{
    int n,a[100000],max=-1000*20000,total=0,p=0;
    cin>>n;
    for(int i=1;i<=n;i++){
    cin>>a[i];
    total=total+a[i];
    }
    if(total>=max)max=total;
    for(int i=2;i<=n;i++){
    for(int j=1;j<=n;j++){
            total=0;
            p=0;
    for(int l=j;l<=n;l=l+i){
    if(l<=n){total+=a[l];p++;}
            }
    if(total>=max && p>=3)max=total;
            }
            }
     cout<<max;
     return 0;}