#include <bits/stdc++.h>
const int N = 400;
int n, m, a[N], dp[N + 1][N][N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      dp[0][i][j] = a[j] - a[i];
    }
  }
  for (int l = 1; l <= n; ++l) {
    for (int i = 0; i < n; ++i) {
      int p = i;
      for (int j = i + 1; j < n; ++j) {
        while (dp[l - 1][i][p] < a[j] - a[p]) {
          p++;
        }
        dp[l][i][j] = std::min(dp[l - 1][i][j], dp[l - 1][i][p]);
        if (p > i) {
          dp[l][i][j] = std::min(dp[l][i][j], a[j] - a[p - 1]);
        }
      }
    }
  }
  long long result = 0;
  for (int i = 0, f, t, c, r; i < m; ++i) {
    scanf("%d%d%d%d", &f, &t, &c, &r);
    result = std::max(result, 1LL * dp[r][f - 1][t - 1] * c);
  }
  std::cout << result << std::endl;
}
