#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int& x : a) cin >> x;
  unordered_set<int> check;
  ll mn = INT_MAX;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (check.count(i)) continue;
    int idx = (i + k) % n;
    ll cur = a[i];
    check.insert(i);
    while (idx != i) {
      check.insert(idx);
      cur += a[idx];
      idx = (idx + k) % n;
    }
    if (cur < mn) {
      mn = cur;
      ans = i + 1;
    }
  }
  cout << ans << "\n";
}
