#include <bits/stdc++.h>
using namespace std;
const int N = 403;
const int M = 25e4 + 3;
int n, m;
int a[N];
int dp[N][N][N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int len = 1; len <= n - 1; len++) {
    for (int l = 1; l <= n - 1; l++) {
      int r = l + len;
      if (r > n) break;
      int pre = l + 1;
      for (int k = r - l - 1; k >= 0; k--) {
        if (k == 0) {
          dp[l][r][0] = a[r] - a[l];
        } else {
          int ans = 2e9;
          for (int cut = pre; cut < r; cut++) {
            if (r - cut < k) break;
            int cur = max(a[cut] - a[l], dp[cut][r][k - 1]);
            if (cur <= ans) {
              pre = cut;
              ans = cur;
            } else
              break;
          }
          dp[l][r][k] = ans;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      for (int k = j - i; k <= n; k++) {
        dp[i][j][k] = dp[i][j][j - i - 1];
      }
    }
  }
  long long res = 0;
  while (m--) {
    int l, r, k;
    long long c;
    cin >> l >> r >> c >> k;
    res = max(res, 1ll * dp[l][r][k] * c);
  }
  cout << res;
}
