#include <bits/stdc++.h>   using namespace std;   const int mod = 1e6 + 3;   int toint(string s) {     int ans = 0;     for (char x : s) ans = ans * 10 + (x -  0 );     return ans;   }   int lcs(string a, string b) {     int n = a.size(), m = b.size();     int dp[2][m + 1];     for (int i = 0; i <= n; i++) {       for (int j = 0; j <= m; j++) {         if (i == 0 || j == 0)           dp[i % 2][j] = 0;         else {           if (a[i - 1] == b[j - 1])             dp[i % 2][j] = 1 + dp[1 - i % 2][j - 1];           else             dp[i % 2][j] = max(dp[i % 2][j - 1], dp[1 - i % 2][j]);         }       }     }     return dp[n % 2][m];   }   int sum(int x) {     int s = 0;     while (x) {       s += x % 10;       x /= 10;     }     return s;   }   bool equal(string s) {     for (int i = 0, j = s.size() / 2; j < s.size(); i++, j++) {       if (s[i] != s[j]) return false;     }     return true;   }   long long fact(int n) {     long long ans = 1;     for (int i = 2; i < n + 1; i++) ans = (ans * i) % mod;     return ans;   }   unsigned long long f(long long a, long long x) {     if (a < 0) return 0;     return (a / x + 1);   }   bool comp(pair<int, int> a, pair<int, int> b) {     if (a.second == b.second) return a.first > b.first;     return a.second > b.second;   }   long long power(long long a, long long b) {     if (b == 0) return 1;     long long ans = power(a, b / 2);     ans = (ans * ans) % mod;     if (b % 2 == 1) ans = (ans * a) % mod;     return ans;   }   int main() {     int n, k;     cin >> n >> k;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     int ans = INT_MAX, ind = -1;     for (int i = 0; i < k; i++) {       int j = i;       int total = 0;       do {         total += a[j];         j = (j + k) % n;       } while (j != i);       if (total < ans) {         ans = total;         ind = i + 1;       }     }     cout << ind << endl;   }   