#include <bits/stdc++.h>
using namespace std;
const int maxn = 402;
int n, m, b, c, d, e, dp[maxn][maxn][maxn], a[maxn];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) dp[i][j][0] = a[j] - a[i];
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      int point = i;
      for (int j = i + 1; j <= n; j++) {
        while (point < j &&
               max(dp[i][point][k - 1], a[j] - a[point]) >
                   max(dp[i][point + 1][k - 1], a[j] - a[point + 1]))
          ++point;
        dp[i][j][k] = max(dp[i][point][k - 1], a[j] - a[point]);
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d %d", &b, &c, &d, &e);
    ans = max(ans, 1ll * dp[b][c][e] * d);
  }
  printf("%lld\n", ans);
}
